I am adding push notifications with UrbanAirship. I have these two methods in my AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Create Airship options dictionary and add the required UIApplication launchOptions
NSMutableDictionary *takeOffOptions = [NSMutableDictionary dictionary];
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];
// Call takeOff (which creates the UAirship singleton), passing in the launch options so the
// library can properly record when the app is launched from a push notification. This call is
// required.
//
// Populate AirshipConfig.plist with your app's info from https://go.urbanairship.com
[UAirship takeOff:takeOffOptions];
// Set the icon badge to zero on startup (optional)
[[UAPush shared] resetBadge];
// Register for remote notfications with the UA Library. This call is required.
[[UAPush shared] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];
// Handle any incoming incoming push notifications.
// This will invoke `handleBackgroundNotification` on your UAPushNotificationDelegate.
[[UAPush shared] handleNotification:[launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]
applicationState:application.applicationState];
// Override point for customization after application launch.
return YES;
}
and this method:
// Implement the iOS device token registration callback
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
UALOG(@"APN device token: %@", deviceToken);
// Updates the device token and registers the token with UA. This won't occur until
// push is enabled if the outlined process is followed.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *alias = [defaults objectForKey:@"user_id"];
[[UAPush shared] setAlias:@"test-alias"];
[[UAPush shared] registerDeviceToken:deviceToken];
}
I got them from the UrbanAirship instructions here: https://docs.urbanairship.com/display/DOCS/Getting+Started:+iOS:+Push
But I am confused how I can specify the screen which I want the push notification to land on. Where is that done? And also, my server sends some JSON along with the push. Where and how do I extract the data from that JSON?
Thanks!