We have 2 apps setup for Push Notifications. (A and B)
There are different profiles for each (of course) and we've generated separate certs for each.
App A receives Push notifications just fine, App B doesn't.
Both are talking to the same server - and it does figure out which app it's sending notifications to and uses the correct cert.
I've noticed that if you install both apps on one device, they both get the same Token (which our server tracks per app.). When the server sends a msg in this case, it sends it twice to the same Token - once with each cert. App A will receive the msg, App B won't.
When sending the msgs to both apps, the Apple server responds that all messages were sent correctly with no errors. But the msg never shows up for the one app.
Any suggestions on where to look?
After much searching and looking, I found this question: Iphone - Multiple Apps, Different App ID, Same Token
It points out that you must use a different .certSigningRequest for each app. I checked with our AppStore guy, and he had used the same one for both certs. He fixed that, and now it works!
Related
First of all may be it will be a duplicate question, but due to curiosity I have asked.
I have an application in which push notifications are used, I have prepared, created all the required things for it and at last I have checked the notifications on this link: https://pushtry.com/. All are working well. NOw the problem is that, when admin wants to send the notification from their admin panel the push notifications are not receiving in iOS device.
I have update all the necessary certificates, pem files, methods for iOS 10 etc, but I don't get received the notifictions from admin panel, as per backend, when we send notifications it shows notification send successfully and showing no error for it. I don't know whats wrong going.
Any sugesstions....
First check all the validations or verifications like certificate, pem file and other things are updated on iOS and backend side. This will ensures that nothing error or fault at both ends.
Now reinstall the app in iOS, Clear all notification ids or apns token table from database. On installing the app, you will see there are few apis token available. Now open your admin panel and test again, it will works correctly.
Firstly I want to confirm which certificate you are used for the app developer or distribution.Because there are different ways for sending the notification for both(developer or distribution). Like I am using php services at backend.When I am using developer certificate my backend developer used 'ssl://gateway.sandbox.push.apple.com:2195', $err,
and when I used distribution certificate he used
//'ssl://gateway.push.apple.com:2195', $err.
Thanks
In my iOS application, I have implemented Push Notification. All working fine except some time push comes twice.
I am using Adhoc Builds with Distribution certificate. In Back-end we send request to APNS only once. Also, we request APNS Production server for any calls
I have googled it but didn't find any solution. Can any one confirm me if this is iOS bug or not.
Also, this is random behavior. As about 80% of time I get two notifications for single event.
Any help would be appreciated
My guess is that you have two different tokens registered for the same device, which causes the server to send the notification twice (one for each token, resulting in two messages being sent to the same device).
Push tokens don't usually change, but they can. This can be a result of re-installing the app, changes in the operating system or any other consideration not fully disclosed to us as the app's developers. That is why Apple indicates that you need to send the most updated version of the token whenever the app is launched.
In your case, it's possible that the token changed for some reason and even though you are sending the notification once for each token, you are sending it once to each of the two tokens representing that device. The explanation for why you're only receiving double messages 80% of the time, is that in the remaining 20%, the messages are sent so close to one another that the operating system (or Apple's servers) are blocking them and only sending one.
Can that be the case?
I’m providing this question and answer because I’ve not seen the problem I ran into with the fairly common ‘APNS not working problem’ and perhaps my experience could help others.
One of my apps that I have in the store uses push notifications. Version 1 of the app was working just fine. No problems.
I created version 1.1, tested it on the sandbox APNS (worked fine) and submitted it. Sometime after 1.1 was approved I noticed push notifications weren’t working. My device was not receiving any push notifications, nor was any other user. That naturally led me to believe I’d screwed up something with the certificates or something like that when I created v 1.1. I checked all the normal things - sandbox vs production, certificates, provisioning profiles, etc. No dice.
--My server setup
I’m doing the interaction with the APNS servers myself and whenever I send an APNS message to Apple I got a positive response. My server code opens a connection to the APNS gateway, sends an APNS message for every device that needs one, then closes the connection.
(this next bit is key to the problem)
In the user record in my DB, I keep track if the user installed the dev version of the app or the production version of the app. I keep this as a flag in the user record. I do this for ease of use.
For simplicity sake, I have one script that processes the development users and sends their APNS messages to the sandbox server and separate code that sends the production user’s APNS messages to the production APNS gateway.
All of that was working fine. I’ll save you all the recertification steps and other grief that I did.
As far as I could tell everything was working fine and everything was set up correctly. So I followed the advice of Ms. Rand: “Contradictions do not exist. Whenever you think that you are facing a contradiction, check your premises. You will find that one of them is wrong.”
After too many hours trying to figure out what was going on I finally determined the problem.
I had turned a development user (my wife’s iPhone) into a production user as I thought she had downloaded the production release of the app
For this user, my server was using the deviceID generated from the development app and sending that to the production APNS server
Whenever I would send that device ID to the production server as one of the APNS messages, even though I would get a positive response from the servers, none of the APNS messages to any other devices would work.
Once I flipped her user record back to be a development device, everything began working again.
I verified multiple times that this was the problem.
So, it appears that using a deviceID that’s intended for sandbox APNS interaction and sending it to the production APNS really screws things up.
Hope this helps somebody in the future.
We have developed an iOS app that makes use of push notifications.
Our client wants to distribute the app through their own MDM server. This means they'll compile and sign the app themselves and also have the appropriate APNS certificate, which we include in our server-side application. So far, so good.
Now, the client also wants to distribute the app to other devices that aren't connected to the MDM server. This would mean a different (AdHoc, App Store, ...) distribution channel with a different certificate chain.
How should we handle this on our server side where we send the push notifications to the APNS?
Can we just send every push notification twice, once with each certificate? Do we need to determine which app installation requires which device (depending on the distribution channel)?
This is basically dependent on the way you distribute the app. When distributing if the application identifier is the same it will refer to same app. If it different only it will install multiple times. Means if you have the same app id in both cases its enough to send one notification so that no matter how you distribute it will send the notification. In case if you have changed the app ids yes you have to send that multiple times. Another thing you may do is to change the app id slightly and introduce a wildcard for app id. Which is also fine to send one notification.
Is there anything preventing SENDING a push notification FROM an iOS application? There are reasons for my madness. If so, are there any good examples out there? I have code that should be working and if there is no blocking reason, I will post the code.
I tried on Verizon and AT&T. Would want it over a carrier for now.
Please do not comment on why, etc.
[addition]
This would not be for a public app, testing internal only.
I don't see any reason what this wouldn't work. You'll have to include the push certificate with your application, and your users will have to download a new version of your app every time the certificate expires (which means once a year). You'll also need to send to each device all the device tokens of devices it should send notifications to.
The sending code should be the same as it would be in a server that sends push notifications, but you would have to implement it in objective C.
All in all it doesn't seem like a good idea, since you'll need a server anyway (for each device to get the device tokens of other devices), so it makes more sense that the server will do the sending.
Actually yes - there are a few things that prevent you from sending push notification from iOS.
Even if you manage to install (use in your app) certificates needed to properly connect to Apple's APNS server their policy is to start blocking clients that create many short connections.
So for public app you would need to use a "normal" way of setting up your PHP server that manages communication with APNS. Otherwise many public IP's (devices) using your credentials would lead to blocking your app APNS certificate.
If this would be just for private use then there is no reason not to give it a try.