ios push notification certificates with Back4App - ios

I need to build an update for an iOS application that uses Back4App as backend and we have some push notifications integrated.
The previous version of the app wasn't created by me so I don't have the private key of the previous Push Notification Certificate and I had to recreate them both for Development and Production.
So my questions are:
If I upload the new Push Notification Certificates then will the old versions of the app continue working?
This seems to be a bug in the Back4App Dashboard, because I have added the new certificates, but I can't remove the older ones.
If I try to remove a certificate with the X button the I receive a Forbidden (403) error in the error console of the browser and the removed certificates keeps re-appearing when I refresh the window of the browser. (see attached screenshot)

Considering you are generating the new certificate with a new bundle id, you should keep both certificates uploaded there.
Parse stores in the Installation table the bundle id that the client is using and use the correct certificate for each of them.
Therefore existing users will keep using old certificates and new users (also the existing users that have already updated their apps) will start using the news ones.
Regarding the bug, could you please report it in the web-site chat together with your app id?

Related

What is a right way to generate the Certificates while using FCM

I am amazed to see that When ever I am creating Certificates "Apple Push Notification service SSL (Production & Development)" it is not shown in Profiles
Things are very much changed on Developer portal And after bashing my head many times (deleting and creating different certificates) its is not working for me
What I am doing:
Attempt 1: When I create certificates from certificate menu it did appear on Profile menu (from where we create provisioning profile & selects certificates) but when I create APNs SSL certificate it never appears in provisioning profile menu
Attempt 2: I created separate SSL certificate and created p12 file from them and uploaded them into FCM server and then i created normal certificate and generated Provisioning profile and installing them in xcode it gives me error of not including something for Notification.
So after trying all these I am now not able to run app on device and not able to work around for FCM notification
Question: What steps are needed to create certificate while working on FCM?
"NOTE: Since all interface and working procedures are updated on developer portal is updated so all help on SO and other places are out date. Please let me know what should I do and how it is done in precise manner it will be great help. THANKS"
I suggest to use for push notification, .p8 key because this same key will work for both sandbox And production mode.
Use this solution to generate .p8 Key And upload key on firebase read this articles

Firebase + Push + iOS

We encountering a problem during the push notification send in firebase.
Currently we have done these steps:-
We created a new app ID com.company.appname.country (without
assigning it the push notification service)
We have create a development certificate for the app id
com.company.appname.country (this creating a sign key request from local
keychain)
We have create a create a sign key to create the development SSL
certificate for the push notification (using the same key request
created in the step 2)
We have download and install all certificate inside the local current
keychain
We have create a development mobileprovision for the app
com.bossitalia.gobooking.ch selecting all certificates avaialble
We have create a local project with XCode selecting the development
mobileproviion file and the com.bossitalia.gobooking.ch certificated
created in the point 2
After having build successfully problem relates to the notification
is still present.
NB: in this configuration, Firebase application (com.company.appname.country) was configured in the "Cloud Messaging" setting tab by the SSL certificates (both for development and production - aka .p12)
Another test that we tried to do is to configure Firebase application without SSL certificates, but by adopting the current existing API key (created in the developer console).
Also in this last test, notifications seem to not work.
A final test was conduct inside Firebase > Notification tab, where in, when we set a test message for the ios device, a message error
Registration token not registered
compare on the same line of iOS device.
What's can be the problem?

Phonegap + Cordova + Firebase + Push Notification +iOS

i'm new in the world of certificates, and reading aware i had to adapt my flow to various case posted but without resolve the problem as per my current configuration.
Can you please confirm me the flow to produce the certificate app rightly ?
WHAT WAS DONE
App ID creation
Create an App ID (ex. com.dir.app)
Enable for app ID com.dir.app the push certification
Development APNS creation
[keychain] - produce a pair of key by a Certification request (key pair name: com.dir.app.dev)
[dev.console] - upload certificate SSL for the dev push part inside App ID options
Download the certificate com.dir.app.dev.apns.cer
Open it and export it as com.dir.app.dev.apns.p12
Development certificate creation
Go to Development Certificate tab
Create a new Dev. Certificate providing the previous key produced (com.dir.app.dev)
Download the certificate produced and install inside local machine Keychain. Now the key appear to be certified with the downloaded certificate
Export the certificated as com.dir.app.dev.p12
Provisioning creation
[dev-console] Create a new mobile provisioning for dev (iOS App Development) selecting the appID - Here a problem occurs: apple provide a certificates list without showing ANY details about certificates - instead, for production certificates, an expired date as detail is shown. So i tried to perform various tests.
Export it as com.dir.app.dev.mobileprovision
App Key creation
[dev-console] - Go go the Keys tab
Create a new key
Download the new key as com.dir.app.key.p8
Firebase configuration
Create a new application calling it with the same name of app ID created at point 1 (com.dir.app)
Go to the Cloud messaging tab
Select the application com.dir.app
Insert the new APNS key produced in .p8 format with its ID
Phonegap configuration
Add a new key using as .p12 the file produced at point 10 (com.dir.app.dev.p12), as provisioning file produced at point 12 (com.dir.app.dev.mobileprovision) with respective password.
Assumptions
[Phonegap] - Phonegap build finish correctly and keys are correctly selected
[Backend] - The backend system is currently working with another application (for which iOS configuration are suspects ...)
[Token for Push] - The Token is correctly generate by the backend system
Problem
The push notifications are not received by the app installed on ad iPad with iOS 11.2.2
QUESTIONS
During the configuration of Phonegap, i have to provide the .p12 file for the push notification instead the development p12 certificate exported?
I have another application that inside the App ID tab (in the developer console), doesn't have the Push Notification SSL certificates configured: **how is possible that this application (eg. com.dir.alpha) is able to receive the push notification? Is there maybe another way to enable push?
Many thanks in advance.
Simon
Problem was solved resolving this one Firebase + Push + iOS
Based on your system GCM management, after having being sure to have configured properly your GCM creation and registration, you must have to being sure also to are able to send a push by the Firebase > Notification console selecting "Single Device" as push device target.

Update new APNS certificate to GCM

Generated new certificates in Apple Developer Centre.
It's weird i couldn't upload that certificates to GCM and also i couldn't see UPDATE button developer website.
It shows error {{ controller.errorMessage }}
How do I do that? Here's a screenshot of the Google Developer
You would have to import your GCM project to the Firebase Console (there won't be any changes, see my answer here) and update the certs from there.
While already importing, I would strongly advise toigrate your app(s) to start using FCM.
Same issue I was facing and able to solve !
Background : In my scenario we have an iOS App in the store and all our push notification configured through Google GCM (We were not using FCM). But we had situation where our APNS certificate is just about to get expired and we don't want to make any iOS Release(We had around 4k DAU on the current version)
Once certificate was expired any Notification we sent was throwing InvalidApnsCredentialfrom GCM.
Here is how to get out of this.
Configure you Firebase project. (Make sure you're logged into right Google account - the one you configured for setting up your GCM)
Goto : https://firebase.google.com > GET STARTED
Choose Import Google Project
You must see now all the GCM Project as below - If your logged in with correct account.
Choose the project.
Now your Firebase project is ready. It should look like below.
To Update new certificate.
Choose Setting gear at Overview.
Choose Project Settings
Now choose Cloud Messaging Tab & now you APNs Certificate section is visible.
If Certificate already expired - you must see RED flagged cell with UPLOAD & DELETE options. Upload new APNs certificate using * UPLOAD*.
You got better way to do it, please share your thoughts ! Cheers !

iOS: Production push notifications, Invalid token from APNS server

My app is now available in the app store, so I've downloaded it to my device. The push notifications were working fine during development. I am using JavaPNS to send out the notifications, and I have switch it to point to Apple's production servers.
However, I'm now getting an Invalid Token error back from the APNS servers.
I have the Archive scheme set to "Release", and I have Release set to use this distribution profile:
Inside that provisioning file, you can see that I have the environment set correctly:
Yet I still get the error. When I look in my database, I think the device token the app is returning to me is the same as the development one, so that could be the problem. But I don't know why it would be returning that, given that the app is signed correctly. This is a device I also used for testing, could that be a problem? Any other ideas about what's happening here?
Thanks!
EDIT: I'm not storing a token in my code, Eran's answer suggests that the only other possibilities are an old token in my database, or the app not being signed by a production profile. I'm cleared my database, so I know it's not the former, and as for the latter, I don't see how that could be the case, since I only have one distribution profile, and as I've shown above, it has the "aps-environment" key set correctly. XCode wouldn't even let me use a development profile for app store submission, would it? A few other possibilities:
Is it possible that something being wrong with key I'm sending with my notifications could cause "Invalid Token"? If so, can I regenerate this key for my existing profiles?
Isn't there another provisioning profile contained in the AppID for the purposes of push notifications? Could a problem with that cause the invalid token error?
I re-downloaded the push production certificate and exported it from the keychain as .p12. This seems to have solved the problem. It seems strange though that a bad private key was giving me the "Invalid Token" error.
The device token for production is different than the development one, so if you send a development token to production APNS servers (or vica versa), that's the cause of the problem.
It's possible you didn't remove the development device token from your server when you switched to production.
Or if you are getting the development token from your production app, then either the app is returning a locally stored device token (which you may have stored on your device during development) instead of asking Apple to get a new one, or (if you do ask Apple for a current token and still get the development token) your app is not signed with the production provisioning profile.
MyApp is an iOS app that sends and receives Push Notifications MyApp-to-MyApp using APN token IDs fetched from a database that is kept updated by each MyApp at logon. The Push Notifications are sent by MyApp using the NWPusher framework API.
As long as the project was run in Developer (Debug) mode, sent and received Push Notifications worked perfectly. But, in Production mode, sending Push Notifications would not work.
I went back and completely recreated my AppID, SSL certificates, provisions, etc., but to no avail. Next I used the NWPusher MacOS Pusher app to experiment with sending Push Notifications to MyApp. I configured Pusher to send a Push Notification (to the tokenID of an Ad Hoc distribution of MyApp) with MyApp’s Production SSL certificate, and got the following message in the Pusher log: "Notification error: APN invalid token".
I next noticed that Pusher had a checkbox option “Should use sandbox environment” checked. I unchecked the option and tried it again. This time the Push Notification was sent and then received by the target phone without any errors. This led me to take another look at the NWPusher.connect call:
Swift:
let pusher:NWPusher? = try? NWPusher.connect(withPKCS12Data: pkcs12! as Data, password:APNS_Certificate_Password,environment:NWEnvironment(rawValue:1)!)
which has an environment argument NWEnvironment enum with possible values 0=none, 1=sandbox, 2=production, 3=auto.
Changing rawValue:1 (develop sandbox) to rawValue:2 (production) fixed the problem: Production Push Notifications now work without errors.
xCode 8.0
I had "invalid token" error the after installing of xCode 8.0.
The issue was found here: Project Navigator -> select project (topmost item) -> select project name in Targets menu -> choose Capabilities in top menu -> look at PUSH Notifications section -> click "Fix issue"
Found the root cause for this issue, it is because of bad private key. To resolve this issue just generate a .p12 certificate with .pem . For creating the p12 file with .pem file please follow the below method
Under ios App Bundle IDs menu in https://developer.apple.com/account/ios/identifier/bundle
click the id of your app if in production, add a new certificate if the old one has expired.
Ensure your App Bundle ID com.myapp.mycom matches your Certificate Name com.myapp.mycom

Resources