Here's code that should post a notification (OpenSocial 0.7!):
function sendNotification() {
var params = {};
params[opensocial.Message.Field.TITLE] =
"Title of the notification goes here";
params[opensocial.Message.Field.TYPE] =
opensocial.Message.Type.PRIVATE_MESSAGE;
var body="Text of the notification goes here";
var message = opensocial.newMessage(body, params);
var recipient = opensocial.DataRequest.PersonId.OWNER;
opensocial.requestSendMessage(recipient, message,
onSendNotification);
};
function onSendNotification(resp) {
if (!resp.hadError() && resp.getData().status == "sent") {
alert("The message was sent to the OWNER");
} else {
alert("There was a problem: " + resp.getErrorMessage());
}
};
sendNotification();
Here's code that should post an activity:
function sendActivity() {
var activityParams = {};
activityParams[opensocial.Activity.Field.TITLE] =
'Test activity';
var mediaItems = new Array();
var mediaItem = opensocial.newActivityMediaItem(
opensocial.Activity.MediaItem.Type.IMAGE,
"
http://www.google.com/images/logo_sm.gif");
mediaItems.push(mediaItem);
activityParams[opensocial.Activity.Field.MEDIA_ITEMS] =
mediaItems;
var activity = opensocial.newActivity(activityParams);
opensocial.requestCreateActivity(activity, "HIGH",
onActivitySent);
};
function onActivitySent(data) {
if (data.hadError()) {
alert("Could not send activity update: " +
data.getErrorMessage());
} else {
alert("The Activity was sent");
}
};
sendActivity();
If these don't work, let me know what container you're working on-
activities or notifications may not be supported.
~Arne