Application Tokens from Bundle Identifier

Hello! I've been doing a lot of work with ApplicationTokens, but there is very little documentation. While Apple gives you the FamilyAcitvitiesPicker to get tokens of apps on an iPhone, I need to get the tokens of apps that aren't on the phone.

Example:

Someone can select Instagram even though they don't have it downloaded. Then the application token will get sent to a server. Then a different person who does have Instagram on their phone will receive the token and it will do something with that application.

Because FamilyActivitiesPicker can only select apps on the iPhone that it is running on, FamilyActivitiesPicker is useless to me, leading to my problem:

Creating an ApplicationToken without FamilyActivitiesPicker

This documentation says that I can create an Application (and thus an ApplicationToken) from the bundle identifier

init(bundleIdentifier: String)
       Creates an object that represents the app with the specified bundle 
       identifier.   

However, when I try to use this to get instagrams(or any apps) token, it returns nil every time!

So, finally, my questions:

How do I correctly use this initializer to create an ApplicationToken?

Or, if this won't work for my purposes

Are the ApplicationTokens created by FamilyActivitiesPicker the same across all devices no matter what?

Answered by _lilpit in 801915022

Hey, To my knowledge, you cannot create Tokens from bundle ID, only get them from the FamilyActivitiyPicker.

I can also confirm that tokens are not portable across devices, an Instagram token on device A is not the same as on device B, using it to block apps will just do nothing on device B.

I'm almost certain you cannot achieve what you are trying to do with the current set of APIs provided by Apple.

I believe this is behaving as designed by apple for privacy reasons.

Good luck !

Accepted Answer

Hey, To my knowledge, you cannot create Tokens from bundle ID, only get them from the FamilyActivitiyPicker.

I can also confirm that tokens are not portable across devices, an Instagram token on device A is not the same as on device B, using it to block apps will just do nothing on device B.

I'm almost certain you cannot achieve what you are trying to do with the current set of APIs provided by Apple.

I believe this is behaving as designed by apple for privacy reasons.

Good luck !

Thanks for the reply @_lilpit! It's annoying that Apple's own initializer doesn't even work.

As for the portability, I did some further testing and found some interesting results I'm going to post incase someone comes across this later.

Tokens are not portable across devices unless the devices are in the same family-sharing network. Using json encoding/decoding, you are fully capable of (for example) extracting a token, storing it on a server or something, sending the token to a different device in the same family network, creating a working application token on the other device, and blocking that application.

Despite these findings, there are almost no practical use cases for this so that's sick

Application Tokens from Bundle Identifier
 
 
Q