4

We have integrated Urban SDK using these guidelines.

We have tried to check the push notification using ad hoc profile where we have set below values in AirshipConfig.plist

  • inProduction=YES
  • productionAppKey=OUR PRODUCTION KEY
  • productionAppSecret= OUR PRODUCTION SECRET

Please check the below code which we have implemented in the AppDelegate file of project.


-(void) applicationDidFinishLaunching: (UIApplication *)application
{
.
.
.
.
 UAConfig *config = [UAConfig defaultConfig];
 config.automaticSetupEnabled=NO;
 [UAirship takeOff:config];

 if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
    {
        NSLog(@"------------REGISTER DEVICE------------: >= 8");
        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    }
    else
    {
        NSLog(@"------------REGISTER DEVICE------------: <8 ");
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
         (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
    }
.
.
.
.

}

#pragma mark Remote Notification methods


-(void) application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken // Device Registration
{
    [[UAirship push] appRegisteredForRemoteNotificationsWithDeviceToken:devToken];

}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
    [[UAirship push] appRegisteredUserNotificationSettings];

}
-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
   NSLog(@"%@", error);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    NSLog(@"NOTIFICATION------------ didReceiveRemoteNotification ------------ %@", userInfo);
    [[UAirship push] appReceivedRemoteNotification:userInfo applicationState:application.applicationState];
}

When we are trying to send the notification to the registered device token, the server shows that device token as INACTIVE Device token.

Please show me what should I do for this.

Wandering Fool
  • 2,170
  • 3
  • 18
  • 48
iDev
  • 531
  • 1
  • 5
  • 15
  • Are you actually IN PRODUCTION or are you testing on your device from Xcode? If not, set it to false. – Quentin Hayot Aug 12 '15 at 08:07
  • @QuentinHayot , i have created the build using adhoc profile and testing it in real device. – iDev Aug 12 '15 at 08:32
  • But it's still testing, it's not a release build, so you have to use the Development mode. – Quentin Hayot Aug 12 '15 at 08:37
  • Actully in AirshipConfig.plist there are 5 key values. inProduction,developmentAppKey,developmentAppSecret,productionAppKey,productionAppSecret So if i am using adhoc profile , i should use inProduction = true ,productionAppKey= key,productionAppSecret=secret. Isnt it ? – iDev Aug 12 '15 at 08:47
  • are you making this app for the app store ? – Jecky Aug 12 '15 at 08:56
  • @QuentinHayot : I have tried with Development mode also. its still shows inactive – iDev Aug 12 '15 at 10:32

1 Answers1

0

So, first it looks like you are missing a few app delegate methods.

Urban Airship handles APNS registration. Remove your manual registration calls as UA will just override them, and instead, enable notifications with [UAirship push].userPushNotificationsEnabled = YES;. It should prompt the user to accept notifications, and then the Urban Airship channel should be opted in.

Wandering Fool
  • 2,170
  • 3
  • 18
  • 48
ralepinski
  • 1,756
  • 8
  • 15