Single APNs key on multiple applications in one organisation
Asked Answered
U

1

27

My organisation maintains multiple applications and there's a confusion about how the APNs keys are supposed to be used. We are using firebase to send push notifications.

So far we have two apple keys for two different applications. But cannot create a third key with APNs activated. Apple key APNs error

This question indicates that we're supposed to use the same key for all applications.

My questions are:

If we only can create two keys for one organisation is one supposed to be used for production and one for testing/development?

If we use the same keys for multiple unrelated application (unrelated except that the apps are all created by the same organisation) what stops cloud messages from being pushed to the wrong application. Is it related to identifiers for apps? Are we supposed to create a convention to circumvent the problem of sending messages to the wrong app? ( I don't actually think this is a very valid option. It feels very wrong.)

For example:

  • using topics with a prefix for each app?
  • create device groups, one for each app?

I've asked this question here as well: https://forums.developer.apple.com/message/415911#415911

Unfavorable answered 12/5, 2020 at 8:46 Comment(0)
H
42

The key is used to authenticate to the service. It identifies your organisation to the service.

The reason you can have two keys is so that you can create a new one before revoking the old one if the key is compromised.

When an app registers for remote notifications you receive an identifier that is unique for that app on that device. If you have multiple apps on that device each will get a different identifier.

When you send a push notification the identifier ensures that it gets to the right app on the right device.

You need to ensure that you store the identifier against the right app on your backend (or you may have different backends for different apps).

Hulking answered 12/5, 2020 at 9:4 Comment(9)
Thank you for your answer! What about FCM topics: firebase.google.com/docs/cloud-messaging/android/… ? If I install two different apps with the same key on two devices. How do firebase and apple distinguish between the two different apps? Is it when one creates two applications on firebase and generate two different GoogleService-Info.plist files?Unfavorable
If you use FCM then you need to create a different firebase app for each iOS app, and this is reflected in the GoogleService file as you mentioned. Then the application push notification registration is recorded against the correct application in the Firebase backendHulking
Alright. I see. Just wanted to make sure we don't push random notifications between different apps. Thank you for your help!Unfavorable
If there are 2 keys, does single app will be signed using both keys?Diactinic
What if you have 2 or more firebase projects for the same app, e.g. for production/staging environments, do you need multiple APN auth keys for each firebase project?Australoid
You would have different iOS apps with different bundle ids for the different firebase projects and each would store its own remote notification identifiersHulking
Actually no, I could check and verify that it is legit to use the same APN auth key for the same app ID on different Firebase projects (dev/staging/production), so this is great newsAustraloid
Can I use a single key for the bundle Ids present two different Teams in my apple dev account?Cupcake
Can we use the same APNs auth key from multiple service providers? For example, I want to use the APNs auth key with Firebase Cloud Messaging and FlareLane.Bolger

© 2022 - 2024 — McMap. All rights reserved.