GameThrivePushNotifications.*

Type library
Revision 2014.2381
Keywords GameThrive, Push, Notifications
Sample code Sample Project
Availability Starter, Basic, Pro, Enterprise

Overview

GameThrive is a free push notification service designed specifically for mobile game developers. The GameThrive Corona plugin makes it very easy to integrate push notifications into your Corona Mobile Game.

Sign Up

Get started by signing up for an account.

Platforms

Syntax

local GameThrive = require "plugin.GameThrivePushNotifications"

Functions

Get started sending Push Messages with GameThrive

If you're an Enterprise user check out the GameThrive for Corona Enterprise documentation here. Otherwise, read on...

1. Sign up for a free account on GameThrive.com

GameThrive.com homepage

GameThrive.com homepage

2. If you're developing your game for iOS, follow the directions to make your application certificate push compatible here. You should start with your development certificate, but don't forget to make your Production certificate push compatible too before releasing your game.

3. If you're releasing your game on Android, follow the directions to generate a push notification key and project number here.

4. In your Corona project folder, find config.lua and add the following in a new line after application = {.

-- Push notifications
notification = {
    google = { projectNumber = "############" },
    iphone = { types = { "badge", "sound", "alert" } },
} 

Include just the google or iphone sections if your game is for only one platform. If you will be releasing on Android, set your project number to the value on the Google Developer console (Make sure you followed step 3 first): https://console.developers.google.com.

5. Update the build.settings file in the Corona project folder to contain the following inside of settings = {.

plugins =
{
    -- key is the name passed to Lua's 'require()'
    ["plugin.GameThrivePushNotifications"] =
    {
        -- required
        publisherId = "com.gamethrive",
    },
    -- Android requires Google Play Services with Corona v2014.2381 or later
    ["plugin.google.play.services"] =
    {
            publisherId = "com.coronalabs"
    },

}

6. At the top of main.lua, place the following code.

-- This function gets called when the player opens a notification or one is received when the app is open and active.
function DidReceiveRemoteNotification(message, additionalData, isFirstOpen)
    if (additionalData and additionalData.discount) then
        native.showAlert( "Discount!", message, { "OK" } )
        -- Take player to your game store
    elseif(additionalData and additionalData.bonusCredits) then
        if (isFirstOpen) then
            -- Add credits here
        end
        native.showAlert( "Bonus Credits!", message, { "OK" } )
        -- Take player your game store or inventory
    end
end

local launchArgs = ...
local GameThrive = require ( "plugin.GameThrivePushNotifications" )
GameThrive.HandleLaunchArgs(launchArgs, "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", DidReceiveRemoteNotification)

Replace XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX with your Application Key, available on the Application Settings page on gamethrive.com. DidReceiveRemoteNotification will be called when a user opens a notification. If the app is currently open and active, no notification will be displayed on the device but it will still be received and this method will still be called. The code above is an example, but you can customize the contents of this method to do different things when a user accepts a notification. The additionalData parameter is a table that can be defined when you send a notification from the GameThrive website.

7. That's all! Now just run your app on a device and you will be able to deliver notifications to it from the GameThrive website. People who download your application will be automatically prompted if they wish to accept notifications, and you can send them notifications any time you wish.

Sample Code

You can access sample code here.

Support

More support is available from the GameThrive team: