objective c - App Groups Data Sharing Between Applications iOS -
assuming have following app identifier com.test.product1, of product1 offering group id group.com.test.product1.
i supposed share document product having com.test.product2 of product2 offering groupid group.com.test.product2.
how can share common group group.com.test.product between of these applications?
you can store shared data using app groups, i've tried built in types.
if you're trying store own classes may need @ nskeyedarchiver , nscoding (maybe here).
if can find way use built in types can use app groups follows:
sharing nsuserdefaults data between multiple apps
in order have shared defaults between app , extension or between 2 apps have add app group in settings using following steps:
- in project navigator click on *.xcodeproj file (should @ top).
- to right of project navigator project , targets. under targets click on primary target (should first thing under targets).
- towards top, click on capabilities tab.
- in app groups section click switch right turn app groups on.
- click on + button , add app group named group.com.company.myapp.
- go same place in other apps , group should available select. turn group on each app using shared data.
note: if go apple developer portal (the apple website shows of certificates, identifiers, devices , provisioning profiles) , go identifiers > app groups should see new app group.
to store data:
var userdefaults = nsuserdefaults(suitename: "group.com.company.myapp") userdefaults!.setobject("user12345", forkey: "userid") userdefaults!.synchronize()
to retrieve data:
var userdefaults = nsuserdefaults(suitename: "group.com.company.myapp") if let testuserid = userdefaults?.objectforkey("userid") as? string { print("user id: \(testuserid)") }
Comments
Post a Comment