Our app is being distributed via MDM (AirWatch in this case) as an InHouse app.
We can send APNS messages to the app and all works find, but only when we use the APNS sandbox.
When we use the production APNS server at Apple and the production certificate, Apple rejects the message.
Do InHouse apps distributed with MDM not work with production APN servers at Apple?
The Error we get is, "Apple Error code : Invalid token" when the production APNS server is used.
It seems like your device that you use for test is not bind with server's token or bound with some errors. I'm not sure but it can be an error in your server logic or invalid certificate used. Rather it is a problem with certificates. What kind of provider you use on your server?
Related
I am trying to testflight my app, but when I use notifications I get an error because I have a development APN instead of a production APN. My problem is uploading it to parse. First I created a development SSL Certificate, then I went back and did a Production SSL Certificate, but I am having trouble uploading the Production Certificate because It's not an APN, rather a Apple Push Services. I also created a Distribution Provisioning (ad hoc).
Apples Push Notification service is a bit strange:
On the client side:
If you build your client with Xcode you usually build a "Debug" version of your app. In that case the registerForRemoteNotification method will create a sandbox device token for you.
If you build a "Release" version of your app the same method create a production device token for you.
On the server side:
If you have a sandbox device token you can only send a push notification to that device if you use Apples sandbox Push Notification service with your sandbox SSL certificate.
If you have a production device token then you have to use Apples production push notification service with your production SSL certificate to send a push notification to that device.
The tricky part is:
if you only have a device token you will not know if it is a production device token or a sandbox device token.
if you want to use release and debug clients against the same server, that server has to use the sandbox and the production service at the same time. And you need a mechanism to decide when to use which service.
BTW: there is a nice tutorial by Ray Wenderlich which also contains a useful PHP script for easy testing.
http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
My push notifications are working fine with the sandbox model. I just verified that the production ssl certificate is working both with direct SSL-connection and with AWS SNS. However, my device is still producing the same push token as it produced for the sandbox, and this token is not working for production-level push notifications (rejected as invalid token by Apple server). Is it supposed to work? How can I make sure push notifications are working/will work for users who download the app from the app store?
Create a provisioning profile for "Ad Hoc" distribution, using your production certificate. Sign your app with that and install. Make sure your SSL connection to APNS knows which certificate to use, depending on whether client is production or dev.
My app is not released yet, so you couldn't find it in the App Store. But it is being used by a group of private beta users (through the iOS TestFlight service). And it is hitting my production server, which is the reason for the question.
In the situation described above, what .p12 do I use? the Dev certificate or the Distribution certificate? I am asking because I am not clear on whom the distinction is for. As far as my server is concerned I don't care which one is used. I just need to send push notifications, and as long as the users get them, I am happy. And since I am using my production server, I figure I should use the production/distribution certificate. But I have a suspicion that my server -- dev or production -- has nothing to do with it. And which certificate I use may entirely have to do with the App Store. So will someone please clarify for me? Thanks.
From http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
Development If your app is running in Debug mode and is signed with the Development provisioning profile (Code Signing Identity is “iPhone Developer”), then your server must be using the Development certificate.
Production Apps that are distributed as Ad Hoc or on the App Store (when Code Signing Identify is “iPhone Distribution”) must talk to a server that uses the Production certificate. If there is a mismatch between these, push notifications cannot be delivered to your app.
I have a problem with push notifications in development\distribution (app that talk with production server).
We have the same certificate in test and in productions servers.
When I run my app on device that talk with the test DB (I save device token by email) I'm getting notification, but when the app talk with the production server, I never get notification...
the certificate file is same on both servers
I signing the app in the same way
What can be the problem?
Use the APNs Production iOS type certificate on your production server. If you use the certificate with the same name but with the type "APNs Development iOS" it will not send push notifications.
In Apple development certificate page there are 2 types of certificate:
iOS development
APNs Development iOS
What is the difference?
iOS development : this type of signing certificate called a development certificate to identify yourself,
APNs Development iOS:Establish connectivity between your notification server and the Apple Push Notification service sandbox environment.
iOS development certificate is that provide you development authority (code signing) that provide your application to testing environment for specific devices.
while
APNS certificate allow the "Apple Push notification service " using this certificate. you can able to use "Apple Push notification service " for more detail of APNS refer this link http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 this may help to understand about APNs.
iOS development certificate is used for testing and deburing purpose.
APNS certificate This is used for the push notification service. APNS communicate remote server to apple server for push notifications.