Get production APNS token - xcode

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.

Related

APNS Certificate production

Did I miss something?
I've created some push notifications in Xamarin.iOS and it works perfectly with the Development certificate.
Then I created a Production certificate and it doesn't work.
Does APNS work differently in Production?
Thanks.
There are a few things to doublecheck. Make sure that:
You're using an App Store and Ad Hoc certificate to sign your app.
You're using an Apple Push Notification service SSL (Sandbox & Production) certificate on the server side
The aps-environment value in your info.plist is set to production

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.

Are different certificates used automatically

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.

Unable to push notifications via urbanairship to APNS

I am using the APNS for my app in development mode. I integrated with the Urban Airship as per the getting started document they provided on their portal:
Created the certificate in Apple provisioning portal. Imported the .p12 file to Urban Airship app(in dev mode with debug enabled)
Now when I open the application, it shows me the alert and asks me for the permission to enable notification. Once that is done and I try to test push a message from the Urban Airship portal to my device using the device token generated, I get the common error:
Apple Push service rejected device token "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
I searched on google and found this to be a very common problem; however with no solution. Most answers mention that the prod and dev environment conflict is the cause, however that is not the case in my case as I did not create the prod app in Urban Airship nor in the APNS dev certificate. The settings in my AirshipConfig.plist are:
APP_STORE_OR_AD_HOC_BUILD : NO
Development_App_Key: XXXXXXXXXXX
Development_App_secret: XXXXXXXXXX
(not master secret, just the dev app secret.)
Nowhere did I find the response from any user who asked the question and later got it resolved. So, I am not sure how people resolved it when they got stuck. All suggests to recheck the environment conflicts, which is not there in my case.
If anyone has any idea, please suggest the possible solutions as this is a blocker for our release. Pls also respond if this is a generic error which almost everyone gets with Urban Airship, and if Free UA account is not a feasible service for testing.
I've been fighting with these issues the last few days. The thing that fixed it for me was creating a non-wildcard identifier that was using a development provisioning profile.
Until I did this I was only able to have APP_STORE_OR_AD_HOC_BUILD : YES
Things worth checking:
Provisioning profile is set to development
Application bundle ID matches the Urban Airship bundle Id.
You can check the Urban Airship bundle Id that is used by going to:
Settings
API Keys
(See the right hand side and there should be a box that contains the iOS Bundle ID.)
Finally make sure your keys in the plist all match.
Also as you probably know, you cannot test push notifications with the simulator. I Hope this helps.

Resources