Release Notes: (1.1.5)
  • Fixed an issue - Potential ANR when launch App from notification.

Integration Guide - Native Notification Plugin

Platforms: Android & iOS
Plugin version: 1.1.5

Follow a few steps below to get the plugin integrated in your App in minutes:

[1] Import the NativeNotification[Android|IOS|Universal].unitypackage file to your unity project;

[2] Follow the instructions below to configure the plugin.

· >>> For Android platform, click on the menu item of Unity top menu bar: NeatPlug -> NativeNotification -> Patch Android Configuration. This is for generating a valid AndroidManifest.xml or patching the existing file with NativeNotification support.


· >>> For iOS platform, click on the menu item of Unity top menu bar: NeatPlug -> NativeNotification -> Patch iOS Configuration. This is for automatically adding iOS SDK frameworks, libraries or patching the Info.plist file (if needed) as long as the Xcode project is generated by Unity.

[3] Find NativeNotificationAgent Prefab and NativeNotificationListener Prefab in Assets/Plugins/NeatPlug/Native/NativeNotification/Prefabs/, open the first scene of your game, drag & drop those two prefabs into the scene.

[4] Okay, the integration is done here. Now you can move on to the next steps to use this plugin.

How to use:

  Call the following function to create a notification:

   · NativeNotification.CreateNotification(...) - Create a notification.

  There are other useful public methods that NativeNotification provides, to use them, simply call NativeNotification.methodName().
Show All   
public void CreateNotification(int notifyId, string smallIcon, string largeIconUrl, string title, ... )
/**
 * Create a notification.
 * 
 * @param id
 *           int - Unique identifier of the notification. This parameter can be retrieved
 *                 in the filed "notifyId" of the Dictionary object that is passed in 
 *                 NativeNotificationListener::OnNotificationClicked().
 * 
 * @param smallIcon
 *           string - The smallIcon name. (Leave it null if you want the notification
 *                    icon to be your App's icon, if you want a customized icon other than
 *                    your App's icon, you can update the image: 
 *                    Assets/Plugins/Android/res/drawable/com_neatplug_notification_icon_small.png,
 *                    and pass "com_neatplug_notification_icon_small" for this parameter.)
 *
 * @param largeIconUrl
 *           string - A URL (starts with "http://" or "https://") pointing to a large icon image file.
 * 
 * @param title
 *           string - Title to be shown on the notification.
 * 
 * @param text
 *           string - text to be shown on the notification.	
 * 
 * @param extras
 *           Dictionary<string, string> - Extra data (key/value pairs) attached to
 *                                        this notification that can be retrieved
 *                                        in the App when user taps on the notificaiton.
 *                                        It will be passed in 
 *                                        NativeNotificationListener::OnNotificationClicked().
 * 
 * @param enableLight
 *           bool - If enable the light when a notification is created.
 * 
 * @param lightColor
 *           Color - Set the color of the light, if new Color(0, 0, 0, 0) is passed in, the
 *                   default light will be used if "enableLight" is set to true.
 * 
 * @param enableSound
 *           bool - If enable the sound when a notification is created.
 *                 
 * @param soundUrl
 *           String - A URL (starts with "http://" or "https://") pointing to a sound media file.
 * 
 * @param enableVibrate
 *           bool - If enable vibrate when a notification is created.
 * 
 * @param delaySeconds
 *           float - Time of delay for scheduling the notification (in seconds). After the 
 *                   specified time, the notification will be created, whether your App is 
 *                   running or not.
 * 	
 */
public void CreateNotification(int notifyId, string smallIcon, string largeIconUrl, string title, 
                              string text, Dictionary<string, string> extras, 
                              bool enableLight, Color lightColor, 
		              bool enableSound, string soundUrl, bool enableVibrate,
                              float delaySeconds = 0)
public void CancelScheduledNotification(int notifyId)
/**
 * Cancel a scheduled notification.
 * 
 * @param id
 *           int - Unique identifier of the notification, which you passed in
 *                 CreateNotification() when creating a notification.
 */
public void CancelScheduledNotification(int notifyId)
public void CancelAllScheduledNotifications()
/**
 * Cancel all scheduled notifications.
 */
public void CancelAllScheduledNotifications()

[6] For advanced users who need to handle events, e.g. get notified when the notification is tapped through. Read this:

  Follow the instructions to handle events:

  · Select the dropped NativeNotificationListener gameObject, locate the NativeNotificationListener.cs script, open it and make some modifications.

  These callbacks are exposed in the script, you can supply your own implementations in them.
Show All   
void OnNotificationClicked(string notifyId) { ... }
/**
 * Fired when notification is tapped by the user.
 */
void OnNotificationClicked(string notifyId)
{
    /// Your code here...   
}

[7] Build your App now. To compile for iOS platform, you need to have Xcode installed.

[8] Test and verify if the notification can show up as expected, and if it is clickable. Also it would be helpful for you to address issues if you take a look at the logcat output (Android) or xcode debug console (iOS) to find the debug / error / warning messages.

[EOF] Should you have any questions or encounter any problems while integrating the plugin, please do not hesitate to shoot us an email at support@neatplug.com, we will be more than happy to help you. Thanks for choosing NeatPlug solutions!