Push notifications stop working after packaging iOS app - ios

I have an enterprise iOS app I'm developing which receives push notifications for various features. I have the push notification service installed and working while debugging the app with Xcode and an iPhone X (phone doesn't matter, I've tried multiple and they all seem to work directly from Xcode).
If I package the app and distribute it over the air to the device, I get the normal "Would you like to receive push notifications" (which I agree to), but then it won't receive push notifications.
Things I've checked:
Make sure the device capability "Push Notifications" is turned on.
Make sure the bundle identifier matches.
Verify that the pushID is correct.
Verify that Background Modes: Remote Notifications is turned on.
The only thing I can think of is that maybe when the app is packaged it's flipping something to production rather than development and maybe when I send the push notification it's not able to send to production or something along those lines.
Has anyone had this issue before?

#HarshalBhavsar's answer got me closer. I found the explanation here though:
https://stackoverflow.com/a/35628480/3921182
As it turns out, Apple has a push notification service for development that is separate from distribution(production). When sending the push notification messages to a distributed app, they actually need to be sent to:
ssl://gateway.push.apple.com:2195
rather than
ssl://gateway.sandbox.push.apple.com:2195

Related

iOS push doesn't work when building from xcode

I'm finding a strange discrepancy in the way that iOS push/APNS works for my app. (For background, the app in question uses Cordova together with the phonegap-plugin-push plugin.) If I download the app's current release from the app store, push works just fine. But if I build the app in release mode and run it on a test device using Xcode, no push notifications are ever received. This seems odd because I would have thought that either method produces essentially the same build.
Try to sign you app using distribution certificate while building from Xcode.
Pushes from a released version must be sent to Apple's push server, while pushes from a development server must be sent to Apple's sandbox push server.
The recommended method is that your server code that sends the push sends it to the push server first, and on failure sends it to the sandbox push server. If your server code is written like that, it will handle both released and development versions just fine.
I've seen server libraries that must be configured to either send to the push server or to the sandbox push server. With that setup, you need different servers, one handling released apps, one handling development apps.
Try archiving the app and downloading the archive to your phone, if that works then your server is set up in this very inconvenient way.

iOS Push Notification Programming - Is there a way to disable push notification on iPhone by programming

A few days ago, I got the issue below.
I've been getting notifications for the past several days. The notification had been enabled, and the app was working (I received push notification) until it suddenly didn't yesterday. And when I open the app, it suddenly asks me to enable notification (please see the picture "iOS Push Notification Permission Alert.png")
iOS Push Notification Permission Alert.png
I guessed that my client removed the app and re-installed, so all permissions were lost. But they said that they didn't.
So, How can it happen?
My concerns are:
If notification was enabled, how can it show the alert above again? Is there a possible way?
If notification was not enabled, why have I received the notification for the past several days?
Under which scenario(s), would an app suddenly disable already enabled notification? Is there a way to disable notification permission for the app on the iOS phone by programming?
I will appreciate your answers so much!
P/s: I read the post disable push notification in app, but it doesn't help for my questions.
This is only possible if the app is reinstalled or the notifications are turned off from the settings.
There is one setting in iPhone which will allow iPhone to offload the unused apps and if this happened, there will be a cloud icon on the left of app title.The app will be reinstalled when you click it again.
And it seems that it will also happened when the storage of iPhone is not enough.
So I guess this happened in your client's phone.
This setting is in both Setting-iTunes & App Stores-Offload Unused Apps and Setting-General-iPhone Storage-Offload Unused Apps.

Development push notifications suddenly stop working, but test flight push notifications still working

I've been developing an app using Firebase and it's Firebase messaging service for push notifications. I've had push notifications working perfectly for the past month or so, until today. I uploaded my app build onto testflight maybe ~4 days ago and have since still been making changes locally. Yesterday push notifications started acting weird with my just latest firebase token giving an error, and then today there are no errors, the notifications simply don't show up.
I decided to try debugging by sending a push notification straight through terminal and through an app I found "Pusher", but I've used before (without any problems) to send push notifications using my devices token. I got the latest token, and tested it manually through terminal and through the app, and both sent sucessfully but were not received. Thus, it seems the problem is somewhere between the apple servers and my app.
I then decided to checkout to the testflight commit, and the push notifications still weren't working in development. However, when I tested the app on testflight, push notifications did work. I'm incredibly confused, as this seems to imply it isn't an issue with my app or any changes I've made in the past few days (which makes sense as none of them really had anything to do with push notifications). I have two separate certificates, a development and a production for APNS which have expiration dates late in 2018.
If anyone has any insight into why notifications would suddenly stop working in development (while they are still working in production with no code differences between development and production) it would be greatly appreciated.
Multiple developers seem to have this issues right now, so its likely a problem with the push servers themselves. The messages do not even reach the devices.
Maybe this thread will go further:
https://forums.developer.apple.com/thread/86282

GCM push is not received on iPhone 7

My app uses GCM to send push notifications and it all worked great.
Recently, one of subdcribers bought iPhone 7 and wrote to me, that push notifications dont work.
I've checked the logs from GCM - message is sent correctly:
{"multicast_id":6854913573879465744,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1484614306664165%6a57bb166a57bb16"}]}
She does receive other notifications from facebook, viber, etc., so no trouble with network.
Notifications are enabled in general and for my app.
"Do not disturb" is off.
Other subscribers with iOS 10.2 successfully receive notifications on their iPhones 5/6.
Reinstalling the app didnt help. App successfully receives the token, but doesnt receive notifications after.
What else can I check? Thank you.
I think this is a common issue on iPhone7. Check it here. I guess you have done all the workarounds in the link given but still no luck to fix the issue. Maybe this thread might help. Suggested action is to make sure that on your project settings, under the Capabilities Tab, scroll down to Push Notifications and turn it to ON. This automatically generates an entitlements file that contains the key APS Environment.

Testing Amazon SNS for iOS using the Mobile Hub but can't get it to work

Per the title, I'm trying to get AWS SNS push notification to work on iOS device. For testing purpose I wanted try the Mobile Hub (https://console.aws.amazon.com/mobilehub) and work my way on top of the sample app that's given.
I just can't seem to make it work. I know it's difficult to ask for help when it involves a multi layered instructions, but I've spent all weekend wrestling this issue, and just couldn't seem to figure it out.
In AppDelegate, didReceiveRemoteNotification call should receive something when I trigger an SNS within Amazon SNS Mobile Console after selecting a Topic. But this protocol is not being called.
In terms of Provisioning Profile, I've created both Development & Distribution. Tested with both.
In terms of certificates I have tried with both Apple Push Notification service SSL (Sandbox) and Apple Push Notification service SSL (Sandbox & Production). It's obvious you have to select the latter since with the former, the notification permission alert doesn't even show when you install the app. Only does it show when you've installed it with the latter.
I made sure the bundle IDs match.
I've turned on all my notifications on my iphone 6s.
On console I see this success message:
2016-03-30 20:57:57.103 MySampleApp[284:47861] AWSiOSSDKv2 [Info] AWSPushManager.m line:186 | -[AWSPushManager interceptApplication:didRegisterForRemoteNotificationsWithDeviceToken:] | The device token: 435d5se354s38s9ddge2edcs2a3601e18ss9c83e47s629164ebced21s16abb39974sg3
"didFailToRegisterForRemoteNotificationsWithError" never gets called.
"didRegisterForRemoteNotificationsWithDeviceToken" successfully gets called.
I also get this success message on my console:
2016-03-30 21:34:16.635 MySampleApp[321:57551] AWSiOSSDKv2 [Info] PushNotificationViewController.m line:112 |
-[PushNotificationViewController topicDidSubscribe:] | Successfully subscribed to a topic: AWSPushTopic: 0x14c6da770
I'm absolutely lost. Please let me know if there is more info for me to post to solve this issue.
Update: Rohan Dubal, thanks for the comment. Here are the following things you asked me for.
Yes, I have always went from "My Sample App" navigationbar view -> "Push Notifications" row -> "Push Notifications" navigation bar view -> click Demo Push Notifications on the bottom -> the toggle is on (green) and the "topic" line is checkmarked and I have sent the APNS to that referring Topic.
Yes I've tried minimizing and also closing the app as well. The top bar notification or any notification doesn't show at all.
Thanks for your feedback. Please do suggest any other tests I can run.
Also, I thought that maybe it has to do w/ my iphone 6s so i tried it w/ iphone 5s and it still doesn't work.
iphone 6s is ios9.2 and iphone 5s is ios 8.3.
Well, this sounds similar to the problem that I was just having. Mobile Hub only seems to let you setup Production APNS and not Development ones. When I debug the app with XCODE I'd need to use the sandbox APNS, so I did the following:
Create an SNS Application of type Apple Development (APNS_SANDBOX)
Use the .p12 from my Development Certificate in the App ID
Started my App and recorded the device token that didRegisterForRemoteNotificationsWithDeviceToken gave me
Minimised my App (otherwise notifications don't appear)
in SNS console I registered an Endpoint using the device token
Used the Publish to this Endpoint button in SNS console to send a message ('Hello World', obviously)
Saw notification
Did engineers victory dance
Hopefully that helps you. The key to this for me was realising that I'd need to create another SNS queue. TBH I'm not seeing the benefit of the Mobile Hub.

Resources