Я пытаюсь отправить квитанцию на веб-сайт, когда push notification
был доставлен на телефон независимо от состояния приложения (на переднем плане, в фоновом режиме, в закрытом состоянии). Я прикрепил свой код, и iGotIt - это всего лишь вызов https
на сервер, который не вызван. Что мне нужно сделать, чтобы заставить приложение что-то делать, когда оно получает push notification
?Получение уведомления о нажатии
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
[application registerUserNotificationSettings:
[UIUserNotificationSettings settingsForTypes:
(UIUserNotificationTypeSound |
UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge) categories:nil]];
[application registerForRemoteNotifications];
}
else
{
[application registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge |
UIUserNotificationTypeSound |
UIUserNotificationTypeAlert)];
}
NSDictionary *userInfo = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
NSString *messagePre = nil;
NSString *message = nil;
id alert = [userInfo objectForKey:@"aps"];
if ([alert isKindOfClass:[NSString class]]) {
messagePre = alert;
} else if ([alert isKindOfClass:[NSDictionary class]]) {
messagePre = [alert objectForKey:@"alert"];
}
NSArray *messageSplit = [messagePre componentsSeparatedByString:@"|"];
serviceID = [messageSplit objectAtIndex:0];
message =[messageSplit objectAtIndex:1];
UIAlertView *alertRC = [[UIAlertView alloc]initWithTitle: @"New Road Call"
message: message
delegate: self
cancelButtonTitle:nil
otherButtonTitles:@"View",nil];
[alertRC show];
//Accept push notification when app is not open
if (userInfo) {
[self iGotIt];
}
return YES;
}
Заранее спасибо за любую помощь вы можете предоставить