Notifications

Skip to end of metadata
Go to start of metadata

Note: Game Mechanics is a premium platform that requires separate activation. If Game Mechanics is not part of your site package please contact your Gigya Account Manager or contact us by filling in a support form on our site. You can also access the support page by clicking "Support" on the upper menu of Gigya's site.

 

Introduction

The Game Mechanics (GM) Notifications add-on notifies the user of his latest achievement, and allows him to share this to his social networks.

The add-on is displayed as a popup window on the right hand corner of the page, and appears whenever the user unlocks a new level of any of the active challenges.

Each site may have one or more challenges, and each challenge has defined levels. Each level has a badge associated with it, and a level title. A user may achieve a level in a certain challenge by performing certain actions and/or earning a certain number of points. To learn more about Gigya's Game Mechanics, refer to our Game Mechanics Guide.

The Notifications add-on displays the user's new achievement:


 

The Notifications popup window is divided into a header, body, and footer, and displays:

Header:

  • A header alerting the user of the new achievement

Body:

  • The badge of the newly unlocked level
  • The title of the new level
  • The description of the challenge as defined in the Challenge Settings page at Gigya's site.

Footer:

  • Display the title of the next level and how it can be reached, if applicable
  • A share button.

Next Level Information

The contents of the footer section in the Notifications popup changes depending on:

If an Action URL has been defined for the next level, the footer displays:

  • "Learn how to unlock the [next level name] badge"
  • This text is linked to the Action URL where the user can find further information
  • There is a grayed-out badge of the next level.

If an Action URL has not been defined for the next level, and this next level is point based, the footer displays:

  • "[Number] points more to unlock the [next level name] badge".
  • This text is not clickable.
  • There is a grayed-out badge of the next level.

For action based levels or levels that are mixed (require both points and specific actions for unlocking), if there is no Action URL defined, the footer section of the popup is empty.

The Share Button

Pressing the Share button opens the Share add-on with the challenge information:

The Share add-on allows the users to publish their achievements to various social networks. Learn about the Share add-on here.

Quick Start Implementation

Adding the Notifications add-on is simple, and involves only adding one line of code:


Add the following code snip to the of your page to activate the Notifications add-on:

gigya.gm.showNotifications();

Like every Gigya API method, the gm.showNotifiaction API method receives one parameter - parameters object, which is empty in this case; all parameters of the Notifications add-on are optional, so there is no need to define the params parameter of the gm.showNotifications API method (learn more about Gigya's basics here). 

There are additional optional parameters. Please refer to the method's parameters table for the entire list of optional parameters.

 

 

A Working Example

In the GM add-ons demo you will find a complete working example of a web-page that uses all GM add-ons, including the Notifications add-on. You may view the code, run it and view the outcome.

 

 

Customizing the User Action

Please see UserAction JS for specific information on the User Action.

The userAction object needs to be used for sharing the user's achievement, and it is comprised of several optional elements, such as title, description, etc. The newsfeed item that is published to the social networks is constructed from the fields of this userAction object.

If a userAction object is not defined, the add-on uses a default userAction object, the content of which is suited to sharing the user's achievement. You can customize the user action by constructing a new userAction object, filling it with data, and adding it to the add-on's parameters (below).

Construct a new userAction object using the userAction object constructor:

var notificationUA = new gigya.socialize.UserAction();

Change the default user action, by using the various UserAction member methods to set the object's properties. For example: 

notificationUA.setTitle('$challengeTitle');

notificationUA.setDescription('*** Challange title: $challengeTitle *** Level title: $levelTitle *** Challange description: $challengeDescription ***');

notificationUA.addImage('$badgeURL');

Add the userAction object to the add-on's parameters:

var notificationParams = {

	userAction:notificationUA

}

Pressing the Share button in the Notifications add-on will now open the Share add-on with the new user action properties:

 

 

 

You can refer to the Advanced Sharing guide to learn more about the UserAction object and how to implement the full richness of newsfeed reports, including adding various media items (Images/ a Flash file/ Mp3 file/ a Video).