我们正在使用离子框架和MobileFirst Platform Foundation 7.1开发混合移动应用程序。该应用程序支持推送通知,我们正在尝试从命令行发送通知。
完成所有设置后,在尝试发送推送通知时,我们收到成功响应 - 但未在Android设备中收到通知。我还订阅了设备以进行推送通知并对其进行了标记。
标记我的应用程序的代码:
<procedure name="sendBroadcastNotification" />
<procedure name="sendTagNotification" />`
};
adapter.xml中的更改:
function sendBroadcastNotification(applicationId, notificationText) {
var notificationOptions = {};
notificationOptions = getNotificationOptions(notificationText);
WL.Server.sendMessage(applicationId, notificationOptions);
return {
result : "Notification sent to all users."
};
}
function sendTagNotification(applicationId,notificationText, notificationTags) {
var notificationOptions = {};
notificationOptions = getNotificationOptions(notificationText, notificationTags);
WL.Server.sendMessage(applicationId, notificationOptions);
return {
result : "Notification sent to users subscribed to the tag(s): '" + notificationTags + "'."
};
}
function getNotificationOptions(notificationText, notificationTags){
var notificationOptions = {};
notificationOptions.message = {};
notificationOptions.target = {};
notificationOptions.settings={};
if(notificationTags != undefined && notificationTags != null){
var tags = notificationTags.split(",");
notificationOptions.target.tagNames = tags;
}
notificationOptions.message.alert = notificationText;
// set raw notification properties for MPNS
notificationOptions.settings.mpns = {};
notificationOptions.settings.mpns.raw = {};
notificationOptions.settings.mpns.raw.payload = {"custom":"data"};
// set toast notification properties for MPNS
notificationOptions.settings.mpns.toast = {};
notificationOptions.settings.mpns.toast.text1 = "Toast title";
notificationOptions.settings.mpns.toast.text2 = "Toast content";
// set tile notification properties for MPNS
notificationOptions.settings.mpns.tile = {};
notificationOptions.settings.mpns.tile.title = notificationText ;
notificationOptions.settings.mpns.tile.count = 1;
// set raw notification properties for WNS
notificationOptions.settings.wns = {};
notificationOptions.settings.wns.raw = {};
notificationOptions.settings.wns.raw.payload = {"custom":"data"};
// set toast notification properties for WNS
notificationOptions.settings.wns.toast = {};
notificationOptions.settings.wns.toast.launch = {"custom":"data"};
notificationOptions.settings.wns.toast.visual = {};
notificationOptions.settings.wns.toast.visual.binding = {};
notificationOptions.settings.wns.toast.visual.binding.template="ToastText04";
notificationOptions.settings.wns.toast.visual.binding.text=[{"content":"Text1"},{"content":"Text2"},{"content":"Text3"}];
// set tile notification properties for WNS
notificationOptions.settings.wns.tile = {};
notificationOptions.settings.wns.tile.visual = {};
notificationOptions.settings.wns.tile.visual.binding=[{"template":"TileSquareText04", "text": [{"content":"Text1"}]}, {"template":"TileWideText04","text": [{"content":"Text1"}]}];
// set badge notification properties for WNS
notificationOptions.settings.wns.badge = {};
notificationOptions.settings.wns.badge.value = 10;
return notificationOptions;
adapter-impl.js中的更改:
E:\mfp projects\SampleMFP7\SampleMFP7P>mfp adapter call
? Which adapter do you want to use? httpAdapter
? Which endpoint do you want to use? httpAdapter/sendTagNotification
? Enter the comma-separated parameters: "com_ibm_SampleMFP7","hello","tag1,tag2"
? How should the procedure be called? GET
Calling GET '/SampleMFP7P/adapters/httpAdapter/sendTagNotification?params=["com_ibm_SampleMFP7","hello","tag1,tag2"]'
Response:
{
"result": "Notification sent to users subscribed to the tag(s): 'tag1,tag2'.",
"isSuccessful": true
}
}
CLI命令:
class Animal { ... }
class Mammal: Animal { ... }
class Platypus: Mammal {
override func walk() {
if something {
Animal.walk(self: self)
} else {
Mammal.walk(self: self)
}
}
}
任何帮助将不胜感激!