button action from OneSignal notification?
In AppDelegate.m
[OneSignal initWithLaunchOptions:launchOptions appId:@"put app ID here." handleNotificationReceived:^(OSNotification *notification) { NSLog(@"Received Notification - %@", notification.payload.notificationID); } handleNotificationAction:^(OSNotificationOpenedResult *result) {
// This block gets called when the user reacts to a notification received
OSNotificationPayload* payload = result.notification.payload;
NSString* messageTitle = @"OneSignal Example";
NSString* fullMessage = [payload.body copy];
if (payload.additionalData) {
if(payload.title)
messageTitle = payload.title;
if (result.action.actionID)
fullMessage = [fullMessage stringByAppendingString:[NSString stringWithFormat:@"nPressed ButtonId:%@", result.action.actionID]];
}
} settings:@{kOSSettingsKeyInFocusDisplayOption : @(OSNotificationDisplayTypeNotification), kOSSettingsKeyAutoPrompt : @YES}];
[OneSignal IdsAvailable:^(NSString *userId, NSString *pushToken) {
if(pushToken) {
NSLog(@"Received push token - %@", pushToken);
NSLog(@"User ID - %@", userId);
}
}];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]]; }
上一篇: 如何自定义MKAnnotationView的调出泡泡?
下一篇: OneSignal通知中的按钮操作?