Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get the app group identifier from host app and share extension on iOS?

I have set up App Groups for both my host app and the share extension. The identifier looks like "group.com.abc.xyzApp". Is there a way to get this string out programmatically? Also, how do I detect if app groups are set programmatically? Is trying to initialize a file container or user defaults with the app group identifier enough to know? Eg:

[[NSUserDefaults alloc] initWithSuiteName:@"group.com.abc.xyzApp"].

like image 962
Shwethascar Avatar asked Mar 12 '16 00:03

Shwethascar


People also ask

What is iOS group app?

App groups allow multiple apps produced by a single development team to access shared containers and communicate using interprocess communication (IPC). Apps may belong to one or more app groups. For iOS, format the identifier as follows: group.<group name>

How do I share data between iOS apps?

User Defaults Group You have to enable app groups in both your app's and extension's targets as well as at the developer's portal. Then you are able to use UserDefaults container which can be shared between several apps (or between the app and the extension).

What is keychain sharing in iOS?

Keychain sharing is used when we want to share some data securely between two or more applications from the same developer. Suppose we want to share some critical data(like username and password) between two apps.

What is the iOS app extension?

App Extensions are an iOS feature that allows developers to extend the functionality and content of their app beyond the app itself, making it available to users in other apps or in the main operating system.


1 Answers

You cannot detect if you get something programatically, but I think this is not very usefull.

Why you need to change this? by environment maybe? If so, you can do it by project variables and then add this to your info.plist

enter image description here

enter image description here

Later you can get it with:

main.object(forInfoDictionaryKey: "AppGroupId") as? String

Hope this helps

like image 55
Sulfkain Avatar answered Oct 30 '22 22:10

Sulfkain