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. If you're releasing your game on the Amazon App store for Amazon devices follow our intructions to setup a Client ID and Secret. Put the app_key.txt you created in those intructions into the root of your Corona project folder. After you follow the rest of the steps but before you build from Corona change the Target App Store setting to Amazon.

5. 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, ["android-kindle"]=true },
    },
}

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

UIBackgroundModes = {"remote-notification"},

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, 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.

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.

Custom Notification Sounds

Displayed notifiations will use the default system sound but you can add your own .wav and .mp3 files to the root of your Corona project folder. Then when you send a notificaion from GameThrive enter the sounds file name to use it.

Custom Android & Amazon icons:

By default we use your App's launcher icon for the small notification icon but we recommend creating the following files in your project's root directory to follow the Android standard colors.

You can use the Android Asset Studio to create the above icon sizes and colors for you. You just need to rename the files to match the above names and move the individual files so they are all in your projects root directory.

Lasly if you would like a large full color icon to show up on the left of the notifiation text by default then place an image file named ic_gamethrive_large_icon_default.png 192x192 in size in your root project folder. If you would like to change it based on the notifiation your sending give it any name you like then enter its name in the Large Icon field on our site to set it.

Support

More support is available from the GameThrive team: