GameThrivePushNotifications.*

Type library
Revision 2014.2393
Keywords GameThrive, Push, Notifications
Sample code Available on GameThrive.com
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. Update the build.settings file in the Corona project folder to contain the following inside of settings = {.

plugins =
{
    ["plugin.GameThrivePushNotifications"] =
    {
        publisherId = "com.gamethrive",
    },
    ["plugin.google.play.services"] =
    {
            publisherId = "com.coronalabs",
            supportedPlatforms = { android=true },
    },
}

If your game is for iOS also add the following line inside of 'plist = {' in build.settings.

UIBackgroundModes = {"remote-notification"},

5. 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, isActive)
    print("DidReceiveRemoteNotification:Messsage: " .. message)
    if (additionalData) then
        if (additionalData.discount) then
            native.showAlert( "Discount!", message, { "OK" } )
            -- Take player to your game store
        elseif(additionalData.bonusCredits) then
            native.showAlert( "Bonus Credits!", message, { "OK" } )
            -- Add credits and take player your game store or inventory if you like
        elseif(additionalData.actionSelected) then -- Interactive notification button pressed
            native.showAlert("Button Pressed!", "ButtonID:" .. additionalData.actionSelected, { "OK"} )
        end
    end
end

local GameThrive = require("plugin.GameThrivePushNotifications")
GameThrive.Init("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. Replace ############ with your Google Project number if your app is for Android. 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.

6. 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: