Push notifications issues: key,failed/message not reach - ios

I'm still new to iOS dev.
And I'm very, very new to whole APNS idea. I followed many tutorials, and didn't go so well.
I'd like to ask some questions.
Can I use same .certSigningRequest file for dev/dist/apns certificates? Does it matter if some of this certificates from this .certSigningRequest have been revoked?
When I export my key in keychain to .p12 file, can I use this one for both dev/distribute version?
If my server open port 2195, by giving .pem generated from above cer, my server should be able to send push message, right?
How can I unsubscribe/unregister from my device and/or from server/apns service? I mean when I need to remove, and try to build&run the code again.
4.1 How does
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
really work? Does it tell apns not to send message/just turn it off? How can my server/provider know if device need to unsubscribe?
I find this tutorial really useful: http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
And here some questions I have about what I encountered.
1. The sample app from the tutorial worked fine, using both my laptop & my server to send a message. But after a few days, it doesn't. (the response is still 'Connected to APNS Message successfully delivered', but the message never reach my device)
What could be the cause? My friend have revoked a dev cert? (I shared acc. w/ my friends) Or I reinstall the app? I also tried method unregisterForRemoteNotifications & register again, but nothing happens.
2. I also tried https://apphq.shephertz.com for a provider. This one requires .p12 key file in their format. (link) I have another project (this one is unity) register apns thru the app. It seems fine since I can see device token & user store in the web. But when I tried to send message, I got an error, like
iOS KeystoreException Device ID : <my-device-token> : Invalid keystore password! Verify settings for connecting to Apple... Does anyone know what this mean?
Sorry for my poor English.

Related

Cannot get push notifications with PEM file

I may sound like noob but I faced a problem and not able to find the solution. I searched all over the google and nothing.
Here is the problem.
I have an app that should receive push notifications. Until iOS 10 everything worked perfect, but now I am not able to receive notifications with my PEM file, instead I can receive them with my P12 file, but PHP won't accept P12, so I am stuck.
I have created my pem-s using this thread link
In my app code is written based on this link
One more thing.
I have tested my push notificatoins also using this website http://pushtry.com/ and in case I use PEM file and TEXT mode, I can receive push, but PEM file and JSON mode does not work. P12 works with both.
I don't know what to do. Please helppppp!!!!
I have found a solution, hope it will solve your problem.
First, use this link: http://apns-gcm.bryantan.info/ and follow their instructions , instead of pushtry.com
Implement all the methods related to remote notifications and make sure all these are updated.
If by mistaken or accidentally your app not enabled notifications for background mode then refer this link: https://www.iphonemanager.org/ios-11-notifications-not-working.html
I have followed these instructions and at my end apns is working.

iOS APNS: Transferring Certificates

I had an app that used the apns with my account certificates .. the owner of the app created a new apple account and i should transfer the apns to it
I make the steps that i did many times but it's not working
I'm using Rails rPush Gem for my server side and it tells me that the notification has been delivered but I got nothing on the phone itself .
Is there any specific steps to do so?
FOllow this tutorial
http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
you will get a file named simplepush.php, add your Device token in the field of $devicetoken and your pen file and run the script if you get the notification then thee is no problem with your certificates

APNS not received after server migration

Our iOS app successfully implemented APNS. Sometimes its not getting received but almost 90% of time its ok.
Now we are required to migrate the whole server-side (which is written in PHP) codes.
After few hours, everything was done and thought migration was completed (all webview was correctly shown, user's data etc.). However, when my colleague try to send push notification to my iOS app, it failed to receive. The server log stating that the APNS was successfully sent and no errors. Interestingly, when he try to send APNS through web browser (hit the URL to send the command), it's successfully received.
Now we don't know where to go from here and don't know what to do. Are we missing some process required in the case like this? For example, should we re-create Certification files for APNS if we want to migrate the whole system? Is there any iOS code at all to modify when the server was migrated? (Other than referral to the server URL. We have already checked that)
I know that the question is too vague but it's just happened and we really can't think of any reason. If there's any guidance for server migration for APNS, it would totally appreciated.
Thanks in advance.
You're right, way too many unknowns to give you a straight-forward answer :)
But, if I understand correctly, when you trigger the PHP from a web browser, the push works. When it's triggered via command line, it doesn't.
Make sure that the user who is executing your script via command line belongs to a group that has enough rights to execute all the statements in your PHP script. For example, if you're using the fwrite command, the user executing the script must belong to a group that has access to the file system.

Ruby apns gem returns nil

I'm trying to get the APNS gem to work with my Rails app. I had originally set this up several months ago, and push notifications to iOS devices worked swimmingly. Now, my app is live and I've found that notifications aren't going out anymore. The APNS gem hasn't been updated in some time, so I've tried various later forks of it, all to the same effect.
Here's what I'm doing:
APNS.host = 'gateway.push.apple.com'
APNS.pem = Rails.root + "lib/push_production.pem"
APNS.port = 2195
APNS.send_notification(device_token, "Test send" )
And the result?
=> nil
There's no feedback from any method, no logfile that I can check. I've tried generating and regenerating my certificate; everything seems okay there. I've tried expressing my device token in various ways, without the angle brackets, without spaces between groups of characters... APNS don't care.
Given the number of moving parts involved in this, I know this is a tough question. But can anyone suggest where to look?
The official documentation says this :
If you send a notification and APNs finds the notification malformed
or otherwise unintelligible, it returns an error-response packet prior
to disconnecting. (If there is no error, APNs doesn’t return
anything.) Figure 5-3 depicts the format of the error-response packet.
So it only makes sense that the gem doesn't return anything, because Apple's server doesn't let it know what it's doing. Also if you look at the gem's github page, the given examples do not handle the return value of APNS.send_notification.
Last time I worked with Apple Push Notifications, it pretty much behaved like a black box, not returning anything most of the time.
I believe I've found the answer. After registering an account with Urban Airship, I tried sending a test message to my phone, and again to no avail. But these guys actually have their act together, so they were able to show me the error message! Turns out my device token was invalid. Why? Because it was generated by the sandboxed version of the app.
Yes, my app is in the store, but it turns out that my App Store distribution profile was generated before the push notification entitlement was added to it. So when you run the codesign tool on my executable, it doesn't show the entitlement. Here's an example:
Diomedes:Release-iphoneos aaron$ codesign -dvvvv --entitlements - Tiberius.app
That command should show a plist that contains the key with a value of "production". My release didn't have that key at all.
I was actually forced to generate an all-new distribution profile in the Provisioning Portal, which finally did include the correct entitlements. I haven't been able to test this yet (8 day App Store review, anyone?) but I feel like this is the problem.
P.S. This article on Urban Airship's site was instrumental in helping me.
This worked for me,
Is your sandbox value correct? Use false for production certificates and use true for development certificates.
P. S. https://github.com/tompesman/push-core/issues/27

APNS - Multiple Certificates in one file (dev and production)

We are developing an iPhone application as well as an iPad application.
Both of them do have different Bundle Identifieres but should receive Push Notifications.
The certificates are generated like documented in apples programming guide.
So, due to the fact that we do have four ceriticates (APNS-Dev-iPhone, APNS-Prod-iPhone, APNS-Dev-iPad, APNS-Prod-iPad) I am wondering how to combine those certificates into one file?
The problem is, that on the backend side we are only storing the device token of a user. It is easy to decide whether we are working in development mode or not,but how should I decide which certificate to use - the ipad one or the iphone one?
Due to the fact, that we only have the device token, we do not know if the user is using the iPad application or the iPhone one, so we cannot assume which certificate to use when connecting to the apns apple server.
Any suggestions on how to handle this issue? Should we store more information - for example the device the user was sending the device token from? Or is there any easier way to combine all the certificates into one file and send it over to the apns apple server?
Thanks in advance, I would appreciate any help!
I have a similar issue and have not found a solution that I find satisfactory.
The way that we handle it is similar to what tGilani described. We have to store some kind of identifier that distinguishes which certificate to send a notification through for a particular device token.
Our issue goes further in that we might possibly have to send notifications to different applications altogether. These applications will probably be on a per tenant basis. Thus creating a universal application and one certificate will not work for us.
It would be terribly convenient if I could find a way to combine multiple p12 files into one jks and continue to use one of the Java PNS or Java APNS projects to send notifications.

Resources