ScheduleLocalNotification ( notification )

Parameters

notification - JSON with id, title, body, channel and either afterSeconds or calendar.

calendar - year, month, day, hour, minute and IANA timeZone (or "local" for the device time zone).

route (optional JSON field) - allowlisted HTTPS route.

Description

Schedules an optional local reminder selected by the player.

Query/request permission first. The ID uses 1–64 letters, digits, dots, dashes or underscores. Choose a configured channel, such as reminders. afterSeconds ranges from 1 to 31622400. Calendar requests name a time zone explicitly and are checked for invalid dates. Android restores schedules after restart and time changes using inexact alarms; delivery may be delayed. No exact-alarm permission is required. A notification-open event is not authorization for a reward.

Returns a positive request ID when accepted, or zero with GameServiceLastError for invalid input or a full queue. Poll for the result and free its event. This command runs on the main runtime and is prohibited in Worker Functions.

See the Game Services guide for configuration and complete samples.

See also: PollGameServiceEvent, GameServiceEventStatus, FreeGameServiceEvent.

Example

; ScheduleLocalNotification Example
; ---------------------------------

Graphics 640,480,0,2
Print "Configure this service in your mobile App Setup."
Print "Run the complete sample for account setup and normal gameplay."

Local notification=CreateJsonObject()
Local value=CreateJsonString("next_round")
JsonObjectSet notification,"id",value
FreeJson value
value=CreateJsonString("Another round?")
JsonObjectSet notification,"title",value
JsonObjectSet notification,"body",value
FreeJson value
value=CreateJsonString("reminders")
JsonObjectSet notification,"channel",value
FreeJson value
value=CreateJsonInteger(3600)
JsonObjectSet notification,"afterSeconds",value
FreeJson value
Local request=ScheduleLocalNotification(notification)
FreeJson notification
If request=0 Then Print GameServiceLastError()
Local deadline=MilliSecs()+125000
While request>0 And MilliSecs()<deadline
    Local event=PollGameServiceEvent()
    If event
        Print "Kind: "+GameServiceEventKind(event)+" status: "+GameServiceEventStatus(event)
        Print GameServiceEventError(event)
        Local payload=GameServiceEventData(event)
        Print JsonStringify(payload)
        FreeJson payload
        If GameServiceEventRequest(event)=request Then request=0
        FreeGameServiceEvent event
    EndIf
    If KeyHit(1) Then Exit
    Delay 10
Wend
Print "Press any key to close."
WaitKey
End

Index