【发布时间】:2017-03-28 13:08:16
【问题描述】:
我正在使用具有推送通知功能的 IBM MobileFirst Platform 8.0 sdk 开发 iOS 应用程序
我设法通过邮递员发送通知,过程是 从 MobileFirst 平台服务器获取令牌 并通过 rest api 连同令牌一起发送通知
我关注的教程链接是,
目前,我正在尝试在应用触发适配器调用时发送推送通知
我目前卡在使用 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'}
}
我可能在这部分做错了,希望得到建议。
提前致谢
【问题讨论】:
-
您似乎在 JSON 中缺少目标:ibm.com/support/knowledgecenter/SSHS8R_8.0.0/…
标签: ios push-notification ibm-mobilefirst mobilefirst-adapters