我最近一直在使用 opensocial,但在使用通知时遇到了麻烦。
我的代码是:
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Notifications" description="" height="300">
<Require feature="opensocial-0.8"/>
</ModulePrefs>
<Content type="html">
<![CDATA[
<script type="text/javascript">
function sendNotification(title, body) {
var params = {};
params[opensocial.Message.Field.TITLE] = title;
params[opensocial.Message.Field.TYPE] = opensocial.Message.Type.NOTIFICATION;
var message = opensocial.newMessage(body, params);
var recipient = "VIEWER";
opensocial.requestSendMessage(recipient, message, callback);
};
function callback(data) {
if (data.hadError()) {
alert("There was a problem:" + data.getErrorCode());
} else {
alert("Ok");
}
};
sendNotification("This is a test notification", "How are you doing?");
</script>
]]>
</Content>
</Module>
当我安装并运行这个小工具时,我没有收到任何警报或通知,我很困惑!
有任何想法吗?