2013-04-05 56 views
0

我最近一直在使用opensocial,但一直在使用通知时遇到问题。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> 

当我安装和运行这个小工具,我没有得到任何警告或通知,而我很为难!

任何想法?

+0

你在哪里测试这个小工具? – 2013-04-07 17:59:59

+0

WebEx Social VM – HelloWorld 2013-04-08 08:51:26

+0

我对该容器不熟悉,不知道它是否支持该API,对此抱歉。 – 2013-04-08 23:11:09

回答

0

发送通知(例如 - 应用程序请求的朋友)我用这个:

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描述了VIEWER和OWNER。想想,你不应该使用VIEWER作为收件人。