1

Bluemix Rest API를 사용하여 알림 메시지와 함께 URL을 전달해야합니다. 문서에 따라Bluemix 푸시 알림에서 URL 태그 값 가져 오기

{"message": { 
"alert": "Notification alert message","url":"test.test.com" }} 

위의 나머지 호출은 메시지와 URL을 보내야합니다. 하지만 알림에서 Json 객체를 구문 분석하려고하면 url을 보내는 태그가 없습니다.

MFPPush.registerDevice(settings, success, failure); 
var notification = function(notif){ 
    alert (JSON.stringify(notif)); 

}; 
MFPPush.registerNotificationsCallback(notification); 
    }} 

위를

enter image description here

내가 코르도바 응용 프로그램을 사용하여 자바 스크립트의 통지를 등록하고있는 코드입니다.

아래 코드 iOS의 AppDelegate에 코드를 보여준다

-(void)application:(UIApplication *)application 

didReceiveRemoteNotification : fetchCompletionHandler 사용자 정보 (있는 NSDictionary *) (보이드 (^) (UIBackgroundFetchResult)) {

[[CDVMFPPush sharedInstance] didReceiveRemoteNotification:userInfo]; 

} completionHandler

AppDelegate에 userInfo에 대한 로그 문을 넣으면 다음 로그가 표시됩니다.

{ 
    aps =  { 
     alert =   { 
      "action-loc-key" = "<null>"; 
      body = test; 
     }; 
    }; 
    payload = "{\"nid\":\"5a379af\",\"tag\":\"Push.ALL\"}"; 
    url = URL; 
} 

사전에 표시됩니다. 그러나 URL 값을 얻는 방법은 무엇입니까?

답변

1

를 열고 응용 프로그램 및 CDVMFPPush.swift 파일로 이동하여 func didReceiveRemoteNotification(notification: NSDictionary?)

이 당신을 도울 것입니다

notif["url"] = notification?.valueForKey("url")

희망 위의 함수 내에서 다음 줄을 추가 찾습니다.

1

@Rahul 알림 팝업에 표시 할 func didReceiveRemoteNotification(notification: NSDictionary?) {} 방법 내에 notif["url"] = notification?.valueForKey("url") 메서드를 추가해야합니다. 엑스 코드에서

+0

나는 정보를 사전에서 가져올 수 없다고 생각한다. 하지만 여기서 문제는 알림 자체에서 URL의 핵심 값 쌍을 가져올 수 없다는 것입니다. –