notifications.*

Type Library
Revision Release 2024.3703
Keywords notification, notifications
Platforms Android, iOS

Overview

Gives access to local and push notifications.

This documentation outlines the legacy notifications plugin, primarily intended for Android apps which have been configured for Google Cloud Messaging (GCM). If you are creating a new Android app or updating an existing Android app with push notifications for the first time, you must use Firebase Cloud Messaging (FCM), supported by the current Notifications plugin.

For new iOS apps, or existing iOS apps being updated with notifications for the first time, you should also implement the current Notifications plugin.

Syntax

local notifications = require( "plugin.notifications" )

Functions

Project Settings

To use this plugin, add an entry into the plugins table of build.settings. When added, the build server will integrate the plugin during the build phase.

settings =
{
    plugins =
    {
        ["plugin.notifications"] =
        {
            publisherId = "com.coronalabs"
        },
    },
}

Android

If your app is for Android and you intend to use GCM push notifications, you will also need to include the following plugin. However, if you only intend to use local notifications, this plugin should be omitted.

settings =
{
    plugins =
    {
        ["shared.google.play.services.gcm"] =
        {
            publisherId = "com.coronalabs",
            supportedPlatforms = { android=true }
        },
    },
}

Additionally, add a notification table to your config.lua file as follows. When you registered with the GCM service, you should have received the projectNumber value needed for the google table.

application =
{
    notification =
    {
        google =
        {
            projectNumber = "YOUR_PROJECT_NUMBER"
        },
    }
}

Solar2D Native

If you're using Solar2D Native for iOS, you'll need to add a reference to the CoronaNotificationsDelegate in your Info.plist as follows:

  1. Add an entry to your Info.plist called CoronaDelegates and make it of type Array.

  2. Add an entry to the CoronaDelegates array and call it CoronaNotificationsDelegate. Ensure this is of type String.