-->

iOS push notification app not asking for permissio

2019-09-07 04:14发布

问题:

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.

回答1:

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.



回答2:

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.



回答3:

After enabling Push notification for you app you need to create SSL certificate then generate new provisional profile.

Hope it resolve your problem