Are different certificates used automatically - parse-platform

I'm building an app that uses Parse to send push notifications. Currently I am in beta and have uploaded both a development and production push certificates. Client side, I add a bool to the Installation object to designate if the client is running a beta version.
When I send a push notification with Cloud Code how do I specify which certificate to use? Is it automatically selected for me? What happens when my app is in production simultaneously with my beta?

I don't use Parse, but I found this in their tutorial :
Note that once you have uploaded a production push certificate to Parse, you will only be able to target devices using a distribution provisioning profile. Devices running an app signed with a development provisioning profile will need to install the newly provisioned build again.
Based on this quote, you can't use Parse simultaneously for both development and production push notifications.

Related

Production Push Notification .p12 Production Certificate not working for Enterprise Distribution App (outside of app store)

I've tried to send push notification using "Development SSL Certificate" or the sandbox .p12 cert the iphone is able to receive notification sent from MobileFirst Operations Console.
However, when I replace the sandbox .p12 cert with the production one, I couldn't receive push notification. I even deleted the device app, remove the device from the registered list and re-register the device. But I'm still getting the same result.
Are there any additional settings needed?
MFP server version is "Product version: 8.0.0.00-20170220-1900"
Update:
From this MobileFirst tutorial Link
"The APNS production certificate can only be tested once the application that utilizes it has been successfully submitted to the Apple App Store."
What about in house distribution app/"save for Enterprise Deployment" outside of the app store?
Please make sure the push notification capability is enabled from the capabilities tab of the project target if you are deploying your application from xcode 8.0 or later.
This should be on if you deploy your application from xcode 8 or later.
For push notifications to be sent, the following servers must be accessible from a MobileFirst Server instance:
Sandbox servers:
gateway.sandbox.push.apple.com:2195
feedback.sandbox.push.apple.com:2196
Production servers:
gateway.push.apple.com:2195
Feedback.push.apple.com:2196
1-courier.push.apple.com 5223
During the development phase, use the apns-certificate-sandbox.p12 sandbox certificate file.
During the production phase, use the apns-certificate-production.p12 production certificate file.
Reference : https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/sending-notifications/#apple-push-notifications-service

Mac app: How to test mac app push notifications on production server?

Currently, I have a server that sends notifications to my Mac App. However, before I release the app I would like to be able to send push notifications to my app using the production key instead of the development (sandbox) key and use the production server. This way I can make sure everything will work fine on the App Store. I know iPhone has adhoc that allows this, but mac doesn't seem to have this option. There is a development profile, but it only works in a development (sandbox) environment. Any way to test mac app push notification in production mode?
Yes, there are ways to test APN with the Apple Push Notification service SSL (Production) certificate, although your app will then be using the production environment instead, and the entitlement will need to be changed:
com.apple.developer.aps-environment from developer to production.
Many push notification servers do not handle error responses or
dropped connections robustly. An easy way to check this is to
intentionally send a notification to a sandbox environment device
token, assuming your server is communicating with the production push
environment. Doing that should return an invalid token response and
drop the connection. To learn more about checking error responses from
the push service, please see Push Notification Throughput and Error Checking
Having two environments allows wiggle room for mishaps while you are building your app. If confident with the way in which the server sends and the app receives APN's in the sandbox then create the production certificate and send yourself a notification to ensure it's working.
Note: There is a separate persistent connection to the push service
for each environment. The operating system establishes a persistent
connection to the sandbox environment for development builds, while ad
hoc and distribution builds connect to the production environment.

When do I update the APN pem

We are using the development APN pem currently.
We are about to submit app to the apple store for review for distribution
Shall we change the APN pem to distribution one now or only after apple's approval?
Currently for beta testing, we are using the build that uses development APN pem
You should not change the Push Notification Cert on your server, instead you should provide one for each environment (development, production). You can create one certificate per environment for your app in the Developer Portal. This approach allows you to test your push notification code and setup from Debug-Builds as well as from AdHoc-, TestFlight- or AppStore-Builds.

Get production APNS token

In development everything works fine:
my app (built with Phonegap) sends the device token to the server
my server sends the notification to the Apple servers
I receive the notification on my iPhone
But, when I switched to production (enabled push notifications and created a new SSL certificate for production) I keep getting "(8) Invalid token" from Rapns (which is installed on my push notification server).
I have read that this message is probably caused because I use a development device token in production (i.e. my server use a production certificate, but the app is running in development and sends a development device token to the server).
How can I run the app in production mode, so that I get a valid device token for production?
I think I should use an Ad Hoc Distribution Provisioning profile, but even if I have changed the "Code Signing Identity" properly in Build settings, I still get the same token I was getting in development! And this obviously doesn't work.
Solved by creating an archive - instead of run - and signing it with an Ad Hoc Distribution Provisioning profile.
You may have to delete the already installed application on the device - do a xcode clean up(for a safer side) - reinstall the application.

How to Deploy Apple Push Notification Certificate to Customer Site

Question: How can I securely include the SSL cert required for push notifications in the installer for my server product?
Background: Apple Push Notifications require a client SSL cert to be in place on the server that's making the calls to Apple.
My product has a traditional client/server architecture, i.e. a customer installs the server within their intranet and then obtains the iOS client from the App Store and connects the client to their instance of the server.
The point here is that the customer installs the server themselves, rather than a cloud architecture where I would manage the server myself.
My problem is that I don't know how to package the push notification certificate in the server installer in a secure way. I can't distribute the .p12 file without a password because that would expose my private key, and I can't use a password because the password would have to be included somewhere else in the installer which would defeat the purpose. Do I need to relay messages from all of my customers through a server that I manage, which has the SSL client cert? Do I need to install the SSL cert by hand into every one of my customers' sites?
Surely others must have run into this problem already? Or has everyone moved to the cloud?
Here is a major observation that happened to me over the weekend regarding Apple Push certificates. While there many references out there to setting up the Apple Push server side certificates, here is a MAJOR point I discovered that I cannot find referenced in any Apple documentation, or via google.
My situation: I have Push Certificates (sandbox) working great on Windows Server. Now it is time for production. Installation of production certs is successful like many times before. However, while the production push transmission completes error free, no pushes are generated to the device. Hmmm.
I just HAPPEN to notice that my Mac's time is roughly a minute off from the Windows Server (command-tabbing between MacOS and VM-Ware). Looking at Windows and Mac Settings, I see Windows internet time is set for "time.windows.com", and the mac for "time.apple.com". Just for kicks, I change the windows server time to "time.apple.com". Instantly, pushes are now being sent to the device. Nice. :-)
I dodged a major bullet here, this would have probably driven me insane trying to figure this one out. I do not claim to be an SSL cert guru... I (like most every one) just want to get this stuff to work because we have bigger fishes to fry.
I hope this is useful information.
I know only the solutions to install certificates for push notifications :
.p12, the password is in the code of the sending
.cer (.p12+private key) the password is requested at the importing of the certificate.
In the first case, you can deploy your solution, and download some code, for example xml with the password.

Resources