Evorlor
Evorlor

Reputation: 7560

How do I schedule a local push notification with Firebase Cloud Messaging?

I am using Firebase with Unity. I am trying to schedule a notification for the user once a timer completes. This time is specific to the user, and not shared across users.

For example, The user is playing a city builder game. They start building their city hall. It will take 5 hours. I want the user to receive a notification at the top of their screen, even though the app is closed, when the city hall is complete.

I can use Cloud Messaging to send a notification to all users. Is there something I can add to the code to schedule a notification locally? Something along the lines of:

string title = "City Hall";
string message = "City Hall is complete!";
var time = DateTime.UtcNow + TimeSpan.FromHours(5.0);
Firebase.Messaging.FirebaseMessaging.ScheduleNotification(title, message, time);

Upvotes: 1

Views: 1023

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599091

There is nothing for displaying a local timed notification (nor for sending notifications on a timer) built into the FCM API. You will have to use the native mechanism of your target operating system (or platform) to display such notifications.

Unity seems to wrap the native notifications of iOS and Android in its Unity Mobile Notifications Package package.

Upvotes: 2

Related Questions