Urban Airship SDK integration on iOS and push notification

We integrated the Urban SDK with these recommendations .

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

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

Please check the code below that we implemented in the AppDelegate project file.


 -(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 try to send a notification to a registered device token, the server displays the device token as an INACTIVE device token.

Please show me what I have to do for this.

+4
source share
1 answer

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

Urban Airship is processing APNS registrations. Delete your registration calls manually, because UA will simply override them, and instead enable notifications using [UAirship push].userPushNotificationsEnabled = YES; . It should prompt the user to receive notifications and then use the Urban Airship channel.

0
source

All Articles