UrbanAirship でプッシュ通知を追加しています。AppDelegate.m にこれら 2 つのメソッドがあります。
- (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 からデータを抽出する場所と方法は?
ありがとう!