0

나는 우체부를 통해 통지를 보내도록 관리IBM 모바일 최초의 플랫폼 - 어댑터

푸시 알림 기능이 IBM MobileFirst 플랫폼 8.0 SDK를 사용하여 iOS 앱을 개발하고에서 푸시 알림을 보내는 과정에서 토큰을 획득 했다 MobileFirst 플랫폼 서버 하고, 토큰

내가 추적이 가지고있는 튜토리얼 링크와 함께 나머지 API를 통해 알림을 보내

서버 측 - https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/sending-notifications/

,

클라이언트 측 - https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/handling-push-notifications/cordova/

토큰 받기 - 지금은 https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/authentication-and-security/confidential-clients/#obtaining-an-access-token

을, 나는 앱이

내가 현재 사용 알림을 보내는에 부착하고 어댑터 호출을 트리거 할 때 푸시 알림을 보내도록 노력하고 있어요 WL.Server.invokeHttp는 아래

,536,913에 문제가 발생하는 나는 것보다 어댑터 코드

function sendPushNotification(message) {  
    var result = getToken();  
    var access_token = "Bearer " + result["access_token"];  

    var requestStructure = { 
     method : 'post', 
     returnedContentType : 'json', 
     path : '/imfpush/v1/apps/my.app/messages', 
     headers: { 
      "Content-Type" : "application/json", 
      "Authorization" : access_token 
     }, 
     parameters : { 
      'message':{'alert' : 'Test message'} 
     } 
    }; 

    result = MFP.Server.invokeHttp(requestStructure); 

    return result; 
} 


function getToken() { 
    var requestStructure = { 
     method : 'post', 
     returnedContentType : 'json', 
     path : '/mfp/api/az/v1/token',  
     headers: { 
      "Content-Type" : "application/x-www-form-urlencoded", 
      "Authorization" : "Basic UHVzaE5vd213123asdsadGlvbjpQdXNoTm90aasdasdWZpY2F0aW9u" 
     }, 
     parameters:{ 
      "grant_type" : "client_credentials", 
      "scope" : "push.application.my.app messages.write" 
     } 
    }; 

    var results = MFP.Server.invokeHttp(requestStructure); 
    return results; 
} 

입니다

parameters : { 
    'message':{'alert' : 'Test message'} 
} 

내가이 부분에서 잘못했을 수도 있으므로 조언을 구하십시오. 사전

+0

당신은 JSON에서 대상을 누락하는 것 : 당신은 다음과 같이 변경 클라우드 .ibm.worklight.apiref.doc/rest_runtime/r_restapi_push_message_post.html –

답변

0

sendPushNotification 방법

덕분에 모바일 최초의 WS를 호출하기위한 잘못된 구문을 사용합니다. https://www.ibm.com/support/knowledgecenter/SSHS8R_8.0.0/com :

function sendPushNotification(message) {  
var result = getToken();  
var access_token = "Bearer " + result["access_token"];  

var requestStructure = { 
    method : 'post', 
    returnedContentType : 'json', 
    path : '/imfpush/v1/apps/my.app/messages', 
    headers: { 
     "Authorization" : access_token 
    }, 
    body: { 
     content: 'message':{'alert' : 'Test message'}, 
     contentType: 'application/json' 
    } 
}; 

result = MFP.Server.invokeHttp(requestStructure); 

return result; 

가}