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は、以下

上の問題を有することに、私はそう多くのアダプタコード

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; 
} 

です ​​

私はこの部分で間違って行ったかもしれませんが、助言を希望します。事前

+0

あなたはJSONにターゲットを逃しているように見える: https://www.ibm.com/support/knowledgecenter/SSHS8R_8.0.0/com .ibm.worklight.apiref.doc/rest_runtime/r_restapi_push_message_post.html –

答えて

0

sendPushNotification方法で

おかげでモバイルファーストでWSを呼び出すための間違った構文を使用します。 あなたはこのようにそれを変更するクラウド:

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; 

}

関連する問題