我最近一直在使用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>当我安装并运行这个小工具时,我没有收到任何警报或通知,我非常困惑!
有什么想法吗?
发布于 2014-07-03 00:25:35
为了发送通知(例如,向朋友发送应用程序请求),我使用以下命令:
var params = {};
params[opensocial.Message.Field.TITLE] = response.response.title;
var msg = opensocial.newMessage("Test request", params);
opensocial.requestShareApp("VIEWER_FRIENDS", msg, function (data) { ... }据我所知,OpenSocial是谷歌的产品,在GoogleDocs上可以找到一些文档。在这里,https://developers.google.com/orkut/docs/on-site-apps/people#viewer_owner描述了查看者和所有者。想一想,你不应该使用查看器作为接收者。
https://stackoverflow.com/questions/15836458
复制相似问题