0

I've been working with opensocial recently, but have been having trouble using notifications.

The code I have is:

<?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>

When I install and run this gadget, I don't get any alerts or notifications, and I'm pretty stumped!

Any ideas?

HelloWorld
  • 29
  • 6

1 Answers1

0

For sending notifications (for example - app request to friends) i use this:

    var params = {};
    params[opensocial.Message.Field.TITLE] = response.response.title;
    var msg = opensocial.newMessage("Test request", params);
    opensocial.requestShareApp("VIEWER_FRIENDS", msg, function (data) { ... }

As i know OpenSocial is google product, and some docs could be found at GoogleDocs. Here https://developers.google.com/orkut/docs/on-site-apps/people#viewer_owner described VIEWER and OWNER. Think, you shouldn't use VIEWER as recipient.

Victor Perov
  • 1,697
  • 18
  • 37