Service Web with APNS serving two apps = two certificates? - ios

I'm developing a iOS app. This app has two targets (free version and premium version). Then I want to send push notifications throw my Service Web.
So, Do I need two certificates? Because my app (free or premium) uses the same Web Service and the same database. And when I want to send a push notification, now do I have to store and look if it's one version or another?
Can I use one certificate? Can I merge two certificates in one?
Thanks.

You can't use one certificate, since each certificate it tied to an App ID, and the App ID is different for each App (it contains the bundle ID of the App which is unique for each App).
You must use two certificates, which means your server will have to know which Device Token belongs to which App, and use the appropriate certificate. Perhaps, when you send the device token from your app to your server, you should send some additional info that indicates which App sent the token).

Related

iOS - What happens I lost my APNs Key file?

I just created the APNs Key file from Apple Developer website. It was saying "Don't lost this key". I already have a backup but what happens if I lost it?
It is also saying I just need one APNs Key for all apps.
Can I create more than one APNs Key or should I go with just one? If I lost this am I going to can't send notifications for just that app or none of my apps?
Thanks in advance.
You can have MULTIPLE .p8 files. The .p8 file is used to generate a JWT Token on the server side and that is used to send push notifications via HTTP2 to Apple's APNS server. Only problem is that if you lose it, you have to regenerate a new one on the server side. It doesn't affect existing apps at all because it's bound to the bundleId, applicationId, and developer account.
In other words, it's not a certificate that the app has to be re-signed with or anything.
Scenario to make it simpler:
I create an app called MyApp with BundleId: com.SO.myApp.
I create an APNS .p8 file with account RT8NCD.
On the server side, I use this .p8 file to send notifications to com.SO.myApp via HTTP2 and JWT Token generation.
I release the app to the AppStore.
I then LOST the .p8 file and can't send push to my app which is already on the store!
What do I do?
I go into the developer portal and re-create a NEW .p8 file with the same AppId and BundleId and same account.
Then on the server side I use this .p8 file to send push notifications to the devices registered in my database.
I do not need to release a new app or new version or anything.
So in other words, there's not really any consequences to losing it.. but it's not a good idea to get into the practice of losing keys, certificates, etc.. Seriously.
P.S. I cannot guarantee that this behaviour won't change in the future. It's Apple. Try not to lose things.
you can create one APN key per app (one for development one for production) but also you can recreate it, and all devices which was registered with all APN will be supported by new key

Is there a pre-built "push" iOS developer app in the app-store?

I'm building a server-side "push" notification capability for various (specific) iOS apps my company makes. I'm not a mobile developer. I understand there's a "p12" certificate I'd need, and that the mobile client must provide the "token" I use to initiate the push from the server.
Does anyone know if there's a pre-built developer/test iOS app in the store that will display a token, has a downloadable cert, etc., and will accept push notifications? I'd like to build the server-side out a bit before I try to plug in the real tokens/certs for my companies apps.
No there isn't, but there are 2 separated environments one for test and one for production.
Usually the app developer team should provide the certificates to the back end developer team.
Once you have your certificates you can integrate them in the backend.
Pay attention that certificates are app specific, they work only for a given identifier.
During test both the team should work together to see if everything work as expected.
Token can be track in a different way, in debug mode using real device by printing them in the console log or by using a particular configuration file, in both cases the device must be connected to Xcode.
You should ask the dev team if they can provide you a sample app that print the token on the device screen and that just send the token to the server to make your experiments.

Can we host two APIs (APNs providers) on single machine who send notification to two different apps?

I am very new to iOS app development and APNs. I have developed two apps which are configured to receive push notification.
In my test environment, I am hosting two APIs apiAppX and apiAppY written using Javapns library on same machine. apiAppX and apiAppY generate push notifications(alerts) for appX and appY respectively. I am using different p12 file for different app.
The problem is, if I generate APNs certificate for appX first then it receives notification but appY doesnt. If I generate APNs certificate for appY first then it receives notification but appX doesnt.
I think this issue is being caused because I am hosting two providers on one machine. I came to conclusion after reading this documentation. Especially, after reading following paragraph:
Note that provider connection is valid for delivery to only one specific app, identified by the topic (bundle ID) specified in the certificate. APNs also maintains a certificate revocation list; if a provider’s certificate is on this list, APNs may revoke provider trust (that is, refuse the connection).
Am I right?
Thanks.

Same APNS token returned by two different applications

How can same APNS token be returned for two different applications installed using profiles created from two completely different apple enterprise accounts?
However the notifications are properly received by the respective applications! just curious to know how apple manages to map with correct device and the right application.
All apps on the same device get the same device token. Apple knows which app should receive the notification because the certificate you use to send the notification is unique for each app.
Seem like up to iOS 6, the token was the same for all apps on the same device, the way to difference them, it was the certificate.
From iOS 7+, the token is unique for each app and device. So every app on the same devices will get a different APNS token.

APNS certificate issue for free and paid version

I have two Applications in iTunes. A free version and a paid version. The paid version does not have advertisement. The two versions have different App Ids.
I have set up APNS for one of the App Ids. How can I handle notifications for both Apps?
Each application requires its own certificate (since each App Id has its own push certificates).
Therefore, your server will have to hold a different certificate for each App, and maintain a separate connection with the APNs server for each App (since you use the certificate to open the connection).
This means that when one of your apps sends a device token to your server, you have to know which app sent the device token, and mark it accordingly in your DB (in order to know which connection to the APNs server to use when pushing a notification to that device).

Resources