[OneSignal Plugin] Get Player id of device in Unity c# for scheduled local notification

[OneSignal Plugin] Get Player id of device in Unity c# for scheduled local notification

  
Forge Component
(9)
Published on 19 Oct by OutSystems R&D
9 votes
Published on 19 Oct by OutSystems R&D

Hi, I am using one signal in my unity game. I want to generate a local notification after some time when user close the game. To do so i need player id of that specific player. 

void pushNotification(int time) {

string userId = "2ac6696c-e701-42f4-9d02-17ed94dd440f";

var notification = new Dictionary<string, object>();

notification["contents"] = new Dictionary<string, string>() { {"en", "Test Message"} };

notification["include_player_ids"] = new List<string>() { userId };

// Example of scheduling a notification in the future.

notification["send_after"] = System.DateTime.Now.ToUniversalTime().AddSeconds(time).ToString("U");

     OneSignal.PostNotification(notification, (responseSuccess) => {

oneSignalDebugMessage = "Notification posted successful! Delayed by about 30 secounds to give you time to press the home button to see a notification vs an in-app alert.\n" + Json.Serialize(responseSuccess);

}, (responseFailure) => {

oneSignalDebugMessage = "Notification failed to post:\n" + Json.Serialize(responseFailure);

});

}


This is my code. Currently i am giving user id explicitly(taken from One Signal Dashboard).

string userId = "2ac6696c-e701-42f4-9d02-17ed94dd440f";

which is working well for my test device. but i want this to run on any device or for every player who plays my game. Can anyone help me in this regard?