방금이 튜토리얼 Push notification을 따라했으며 내 iPhone 앱에 대한 푸시 알림을 성공적으로 구현했습니다. 이제 알림 세부 정보를 얻을 수 있습니다. 그러나 alertBody 알림에 제공된 Label에 알림 alertBody를 넣고 싶습니다.원격 푸시 알림에서 내 앱의 notification.alertBody를 가져 오는 방법은 무엇입니까?
로컬 알림에서 alertBody 알림을 표시하는 코드가 있습니다. 하지만 푸시 알림은 로컬 알림에만 사용되기 때문에 푸시 알림과는 다릅니다. 내 ViewController.m
- (void)viewDidLoad{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserverForName:@"Notification" object:nil queue:nil usingBlock:^(NSNotification *note)
NSString *_string = note.object;
//Do something with the string--------
}];
}
그것은 지역 알림에 있지만, 푸시 알림을 완벽하게 작동 내 AppDelagate.m
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
NSLog(@"Recieved Notification %@",notif);
NSString *_stringFromNotification = notif.alertBody;
[[NSNotificationCenter defaultCenter] postNotificationName:@"Notification" object:_stringFromNotification];
}
에
, 그것은 작동하지 않습니다. 이것을 구현하는 방법? 도와주세요. 레이블 또는 문자열에 알림 경고 본문을 넣어야합니다.