Search code examples
iosiphoneobjective-crubymotion

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.


Solution

  • 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.