Skip to content

Notification

yenmoc edited this page Feb 1, 2024 · 3 revisions

Simple api to push notification in game

First you need to create a notification channel that can be used through the menu

Create > Pancake > Misc > Notification Channel

image

  • Identifier : Unique identifier for the channel
  • Minute: Delay time will send notification
  • Repeat: Does the notification repeat or not?
  • Big Picture: If true this channel will use Name Picture value to fetch image from StreamingAsset to display as big picture
  • Name Picture: File bigpicture must be place in folder StreamingAsset, Name Picture must contains file extension ex .jpg. If it's in a subfolder in a streaming asset, NamePicture must include the relative path

Datas : Contains a list of titles and messages that can be displayed on this channel if more than 1 when scheduled, it will randomize the value in the array to select title and message

NotificationPrepare

image

Is a script to preload bigpicture from streaming asset. It is placed in the PersistentScene, please drag and drop the channels that use bigpicture into the notification variable array so that it can pre-load

Usages

You need to declare property from ScriptableNotificationVariable

[SerializeField] private ScriptableNotificationVariable notiDailyChannel;

// Then

// Send notification immediately
notiDailyChannel.Send();

// Schedule notification after minutes from now
notiDailyChannel.Schedule();

Notes

Google recommends applications that require exact scheduling as a key feature to declare SCHEDULE_EXACT_ALARM and USE_EXACT_ALARM permissions. Applications that do not require exact scheduling and still declare these permissions are prohibited to publish on Google Play. For more information, refer to Google's policy on restricted permission requirement for Exact Alarm API.

[schedule-notifications-at-exact-time] https://docs.unity3d.com/Packages/com.unity.mobile.notifications@2.3/manual/Android.html#schedule-notifications-at-exact-time

In Notification Setting disable Add Use Exact Alarm Permission

image

Clone this wiki locally