OneSignal通知中的按钮操作?
在AppDelegate.m中
[OneSignal initWithLaunchOptions:launchOptions appId:@“把应用ID放在这里。” handleNotificationReceived:^(OSNotification * notification){NSLog(@“Received Notification - %@”,notification.payload.notificationID); } handleNotificationAction:^(OSNotificationOpenedResult *结果){
// 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”]]; }