Notification

Status: Stable

Version: 1.4

Supported platforms:

   

Documentation Forum thread

What's new?

version 1.4
Added didOpen bool to indicate app was opened from notification to the event
Fixed retrieving notification when starting app in IOS (Thanks to Troy Sandal)

About Notification

This is a plugin to manage both Local and Push notifications.
You can schedule, cancel and dispatch local notifications, and also manage scheduled, already dispatched and pushed notifications.
This plugin also allows you to know, when your app was opened through any specific notification

Installation

Android
Copy libs folder into your exported project.
Copy src folder into your exported project.
Add gcm.jar the project
Add System.loadLibrary("notification"); to your main Activity
Add "com.giderosmobile.android.plugins.notification.NotificationClass" to external classes in your main Activity
Modify AndroidManifest as described in installation instructions provided with plugin
Modify Main activity as described in installation instructions provided with plugin
IOS
Copy Plugins/Notification folder int your Xcode project's Plugins folder
Add copied files to your Xcode project
Modify AppDelegate file as described in installation instructions provided with plugin

Code example:

require "notification"

local note = Notification.new(1)
note:setTitle("Test from Lua")
note:setMessage("Do you see me?")
note:setSound("./point.wav")
note:dispatchAfter({sec = 20})

local mngr = NotificationManager.getSharedInstance()

mngr:addEventListener(Event.LOCAL_NOTIFICATION, function(e)
	print("Local notification: "..e.id)
	print("Title: "..e.title)
	print("Text: "..e.message)
	print("Number: "..e.number)
	print("Sound: "..e.sound)
	text:setText("Id: "..e.id)
end)

mngr:addEventListener(Event.PUSH_REGISTRATION, function(e)
	print("Push notification registered: "..e.deviceId)
end)

mngr:addEventListener(Event.PUSH_REGISTRATION_ERROR, function(e)
	print("Could not register: "..e.error)
end)

mngr:addEventListener(Event.PUSH_NOTIFICATION, function(e)
	print("Push notification: "..e.id)
	print("Title: "..e.title)
	print("Text: "..e.message)
	print("Number: "..e.number)
	text:setText("Id: "..e.id)
	local t = mngr:getPushNotifications()
	print_r(t)
end)

mngr:registerForPushNotifications("953841987672")