Skip to content

Local Notifications

Introduction

The tutorial focuses on integrating Mobile Notifications into a Unity project, providing step-by-step instructions to achieve this.

Installing Mobile Notifications

  • Users are instructed to install mobile notifications through the Unity Package Manager.
  • To find the mobile notifications package, users should search for 'mobile notifications' in the Unity Registry and click on 'Install' after selecting the appropriate package.
  • Once installed, users should close the Package Manager and import the necessary scripts for the mobile notifications.

Configuring Project Settings

  • After importing the scripts, users need to navigate to the Project Settings and select the Mobile Notifications section.
  • Icons for notifications must be added, starting with the small icon, which users can drag and drop from the Mobile Monetization Pro UI icon section.
  • It is essential to ensure that the 'Read and Write' option is checked for the icons before applying the changes.
  • Users are also guided to add a large icon by clicking the plus sign, choosing an image, and ensuring the read and write option is also selected for this icon.

iOS Notification Setup

  • For iOS setup, users must check the 'Request Authorization on App Launch' option and enable push notifications.

Creating Notification Objects

  • Users are instructed to create an empty GameObject named 'Mobile Notifications' within the hierarchy.
  • They should then navigate to the folder - Mobile Monetization Pro < Tools < Mobile Notification Manager and drag the relevant script onto this GameObject.
  • In this section, users can set the notification title, description, and subtitle, with examples provided for clarity.
  • The tutorial emphasizes selecting a notification receiving time, which can be set in seconds, minutes, hours, or days.

Finalizing Notification Setup

  • Users are reminded to input the same icon names used in project settings into the notification setup to ensure consistency.
  • Once all settings are configured, the mobile notification setup is complete, allowing users to proceed to build their project for Android.

Local Notifications Script

alt text

Fields Info
DebugTextForiOS Assign a TextMeshProUGUI component here to display debug messages specifically for iOS notification behavior during development. (Optional)
NotificationCycle Specifies how many times the full notification schedule should loop after completing once. Example: If set to 2, the notifications will repeat twice after the first full cycle.
ResetNotificationsWhenGameStart Enable this to reset and re-schedule notifications every time the player starts the game. Disable to continue the original notification schedule without resetting.
NotificationSetup List of notifications to schedule. Each entry defines its title, description, delay time, and icons.
AboutNotification Define the title, body text, and optional subtitle (for iOS) for this notification.
NotificationRecievingTime Set the delay after which this notification should appear. You can specify days, hours, minutes, and seconds.
NotificationIcons Assign custom small and large icons for this notification on Android.
NotificationTitle The title text displayed on the notification.
NotificationDescription The main body text of the notification.
NotificationSubTitleForIOS A subtitle for the notification (used only on iOS devices).
Days Delay in days before this notification is triggered.
Hours Delay in hours before this notification is triggered.
Minutes Delay in minutes before this notification is triggered.
Seconds Delay in seconds before this notification is triggered.
SmallIconName The name of the small icon file (must exist in the Android project Resources).
LargeIconName The name of the large icon file (must exist in the Android project Resources).


🔑 Key Notes:

  • 📱 Notification Grouping on Android: Android may group notifications if you send too many in a short period. Make sure to space them out properly.
  • 📦 Notification Bundles: Newer Android versions may group related notifications into "bundles" to improve the user experience.
  • Notification Channel Registration: The player must play the game for at least 20 seconds after installation to properly register notification channels.
  • 🚫 Notification Limitations: Notifications cannot run indefinitely. Once the last scheduled notification fires, they will not restart automatically unless rescheduled.
  • 🔄 Notification Reset Option: Enable reset to start the notification cycle again when the player opens the game. Otherwise, notifications continue until the set cycle limit is reached.
  • 🔁 Sequential Notifications: Notifications are sent one after the other based on the scheduled time intervals.
  • 🛠️ Understanding Loop Notifications: Unity schedules notifications when the app is running. Even if the app is closed, scheduled notifications will fire. However, scheduling too many notifications may consume more memory and battery — keep loop counts low (preferably 1–2) for best performance.