status (PushStatus) – 수신된 Notification 의 상태, NotNull
messageUUID (NSString) – 앱에서 부여한 수신된 메세지의 고유 ID, NotNull
Example:
-(void)manager:(PushManager*)managerdidReceiveUserNotification:(NSDictionary*)userInfostatus:(NSString*)statusmessageUID:(NSString*)messageUID{PushManager*manager=[PushManagerdefaultManager];NSDictionary*apsInfo=[userInfoobjectForKey:@"aps"];if([apsInfoobjectForKey:@"badge"]){NSNumber*badge=[apsInfoobjectForKey:@"badge"];// 뱃지 숫자 변경manager.notificationCenter.badgeNumber=badge;// 뱃지 숫자 초기화manager.notificationCenter.badgeNumber=[NSNumbernumberWithInteger:0];}// 읽음 확인[managerread:selfnotification:notification.userInfocompletionHandler:^(BOOLsuccess){NSString*message=(!success)?@"Confirming Read-Message is FAIL !!":@"Confirming Read-Message is SUCCESS !!";NSLog(@"%@",message);}];// 알림 메세지NSString*title=[NSStringstringWithFormat:@"PUSH (%@)",status];NSString*message=[apsInfoobjectForKey:@"alert"];if(NSClassFromString(@"UIAlertController")){UIAlertController*alert=[UIAlertControlleralertControllerWithTitle:titlemessage:messagepreferredStyle:UIAlertControllerStyleAlert];[alertaddAction:[UIAlertActionactionWithTitle:@"취소"style:UIAlertActionStyleCancelhandler:^(UIAlertAction*action){}]];[alertaddAction:[UIAlertActionactionWithTitle:@"확인"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction*_Nonnullaction){}]];UIViewController*viewController=[[UIApplicationsharedApplication]keyWindow].rootViewController;if(viewController.presentedViewController){viewController=viewController.presentedViewController;}[viewControllerpresentViewController:alertanimated:YEScompletion:^{}];}else{UIAlertView*alert=[[UIAlertViewalloc]initWithTitle:titlemessage:messagedelegate:nilcancelButtonTitle:@"취소"otherButtonTitles:@"확인",nil];[alertshow];}}
Push 관련 라이브러리 파일들 Target Membership에 NotificationService 타켓 추가
#import <MPushLibrary/MPushLibrary.h> 추가
didReceiveNotificationRequest 메서드 내에 feedback 메서드 추가
Example:
// NotificationService 쪽에서 메시지 수신시 들어오는 이벤트-(void)didReceiveNotificationRequest:(UNNotificationRequest*)requestwithContentHandler:(void(^)(UNNotificationContent*_Nonnull))contentHandler{self.contentHandler=contentHandler;self.bestAttemptContent=[request.contentmutableCopy];//PushManager 초기화PushManager*manager=[PushManagerdefaultManager];//Keychain Sharing을 통해 feedback시 필요한 정보를 획득//키체인 공유 외에도 앱그룹등을 통한 방법으로도 공유가 가능 (app과 extension 사이에 데이터 공유)NSString*app_identifier=[NSStringstringWithFormat:@"%@.pushDic",@"com.uracle.push.demo.NotificationService"];NSDictionary*pushDic=[KeychainControllerloadValueForKey:app_identifierforAccessGroup:@"com.uracle.push.demo.NotificationService"];//관련정보가 없을 경우에는 feedback처리 없이 완료if(pushDic==nil){self.contentHandler(self.bestAttemptContent);return;}else{//데이터 공유시의 값의 정보 출처 샘플//[pushDic setObject:[PushManager defaultManager].info.clientUID forKey:@"cuid"];//[pushDic setObject:[PushManager defaultManager].info.pushServiceID forKey:@"psid"];//[pushDic setObject:[PushManager defaultManager].info.host forKey:@"host"];NSString*cuid=[pushDicobjectForKey:@"cuid"];NSString*psid=[pushDicobjectForKey:@"psid"];NSString*host=[pushDicobjectForKey:@"host"];if(host){//서버 호스트 정보를 셋팅[manager.infochangeHost:host];}if(cuid&&psid){//feedback API 호출//push메시지 객체와 cuid, psid값이 필요[managerfeedback:selfnotification:self.bestAttemptContent.userInfoclientUID:cuidpsID:psidcompletionHandler:^(BOOLsuccess){//앱에서 중복으로 feedback처리를 하지 않도록 메시지 객체에 feedback 정보에 대한 값을 셋팅후 전달NSMutableDictionary*userInfo=[self.bestAttemptContent.userInfomutableCopy];[userInfosetObject:@"true"forKey:@"feedback"];self.bestAttemptContent.userInfo=userInfo;self.contentHandler(self.bestAttemptContent);}];}else{self.contentHandler(self.bestAttemptContent);}}}