我正在使用 UrbanAirship 添加推送通知。我的 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;
}
这个方法:
// 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];
}
我从这里的 UrbanAirship 说明中得到它们:https ://docs.urbanairship.com/display/DOCS/Getting+Started:+iOS:+Push
但我很困惑如何指定我希望推送通知登陆的屏幕。这是在哪里做的?而且,我的服务器会在推送的同时发送一些 JSON。我在哪里以及如何从该 JSON 中提取数据?
谢谢!