2013-04-05 25 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作爲收件人。