iOs Push notifications, don't get alert asking for authorization - ios

I hope you can help me troubleshoot my issue.
When I install my app, I don't get the message alert asking for the authorization to get push notifications.
I am thinking that if I don't get this message it's not my code to be wrong, but maybe it's a matter of certificates.
Am I right? How can I check if my provisioning file is correct?
I am using Xcode 5 and testing on ios7.0.2
I add a little more: I was never able to get the alert working

I had this issue when developing an app, it turned out I'd not set the entitlements up correctly. So make sure you have in your AppDelegate:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
Make sure in Developer Center you've generated an AppID for your application as well, specifying that you want to use Push Notifications. Then you need to generate a Provisioning Profile to use for development/deployment with the device ID you want to install it on. Then you need to bring that Provisioning Profile into Xcode, and apply it to your project within the target build settings. That should bring up the Push Notification alert view to get the permission for the app to use push notifications. You then get the fun of setting up the SSL certificates but that's a whole other topic.
I found the Ray Wenderlich Push Notification Tutorial incredibly helpful when I went through it, I'd recommend following through if you're finding yourself stuck.
Edit; also keep in mind Push Notifications do not work on the Simulator, you must test them against an actual device as you won't see the alert view at all on the Simulator.

If you accept or decline it once this screen would not appear again. Go to setting and check permission for push notifications for your app.
Settings->Notifications->YOUREAPP

In order to see the alertView:
uninstall the app
set the device date to at least 1 day after the current date
Reboot the device
Install and launch the app

Related

Push notifications stop working after packaging iOS app

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

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.

How to remove Notification in Settings in iOS

Using Parse service, I implemented Apple Push Notification service in my app.
This is a link I referred: https://parse.com/tutorials/push-notifications
However, I changed my mind not to use it for now. And then, I deleted all of the codes, but it still remains Notifications in Settings.
Does anybody know how to delete if for all eternity?
Turn it off for the app in the settings and then delete and reinstall the app on the the device.

iOS push notification app not asking for permission on registration

I am working on an app which requires push notifications to be enabled. I have followed this article and worked fine till I downloaded the provisioning profile. I am using Rubymotion to develop this app and hence in my Rakefile I Did this,
app.name = 'Myapp'
app.identifier = 'com.myapp.development'
app.provisioning_profile = '/Users/sunilkumar/Library/MobileDevice/Provisioning Profiles/Myapp_Development.mobileprovision'
'My App' is the name of my app. Identifier is the project identifier (as per the Rubymotion docs and as per my belief thats the bundle identifier ), the default value of which I override to make it same as the App Id which I created in the IOS development center.
In my app_delegate.rb, I also have this piece of code,
UIApplication.sharedApplication.registerForRemoteNotificationTypes(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)
The issue is that when the device is connected and the app installed, the permission for push notifications is not being asked. I guess I have done almost everything right and is as per the article I linked above, but somehow it just doesn't seem to work. Any help on this would be must appreciated.
I think you might have installed this app before. iOS only ask permission for push once a day per application. So, you will need to change the system time ahead 2 days or more, reboot the device then change systime back. This will make permission alert be asked again.
Figured it out guys.
I had to set the aps-environment in my RubyMotion project's Rakefile.
app.entitlements['aps-environment'] = 'development'
app.entitlements['get-task-allow'] = true
As soon as I did, it worked for me. Thanks all for the responses.
After enabling Push notification for you app you need to create SSL certificate then generate new provisional profile.
Hope it resolve your problem

Push Notification iOS resetting

I want to reset the push notification setting for my app. I have read the apple documentation regarding resetting the settings (which didn't help) and some questions here as well (which didn't help either). So in the last I reset my iPhone by going to settings->General->Reset ->Erase All Content and Settings (That didn't worked as well.)
Any other solution?
BTW I am using iOS 6.1
https://developer.apple.com/library/archive/technotes/tn2265/_index.html
The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.
You can also move your clock by a day after uninstalling the app and try.

Resources