![](/img/trans.png)
[英]Push Notifications in IBM MObile First: Which is better for sending push notification, MobileFirst Operations Console or via REST APIs
[英]IBM Mobile First Platform - Sending Push Notification from adapter
我正在使用具有推送通知功能的IBM MobileFirst Platform 8.0 SDK開發iOS應用程序
我設法通過郵遞員發送通知,該過程是從MobileFirst平台服務器獲取令牌,然后通過rest api和令牌發送通知
我遵循的教程鏈接是,
服務器端-https: //mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/notifications/sending-notifications/
目前,我正在嘗試在應用觸發適配器調用時發送推送通知
我目前無法使用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;
}
我似乎在遇到問題
parameters : {
'message':{'alert' : 'Test message'}
}
我可能在這方面做錯了,希望能提供建議。
提前致謝
sendPushNotification方法使用錯誤的語法在Mobile First中調用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;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.