public void ResetBadgeNumber() { if (Application.platform == RuntimePlatform.Android) { AndroidNotificationManager.Instance.HideAllNotifications(); OneSignal.ClearOneSignalNotifications(); } else if (Application.platform == RuntimePlatform.IPhonePlayer) { IOSNotificationController.Instance.ApplicationIconBadgeNumber(0); } }
public static void someMethod(int day) { OneSignal.ClearOneSignalNotifications(); // Just an example userId, use your own or get it the devices by calling OneSignal.GetIdsAvailabl var notification = new Dictionary <string, object>(); if (Application.systemLanguage == SystemLanguage.Russian) { notification["contents"] = new Dictionary <string, string>() { { TextManager.getText("push_locale_text"), TextManager.getText("push_" + day.ToString() + "_text") }, { "en", "Cats prepared a gift! Come and get it!" } }; } else { notification["contents"] = new Dictionary <string, string>() { { TextManager.getText("push_locale_text"), TextManager.getText("push_" + day.ToString() + "_text") } }; } notification["include_player_ids"] = new List <string>() { Id }; //Test!!!! var additional_hours = 24 - System.DateTime.Now.Hour + 17; //var additional_hours = 24 - System.DateTime.Now.Hour + 8; // Example of scheduling a notification in the future. notification["send_after"] = System.DateTime.Now.ToUniversalTime().AddHours(additional_hours).ToString("U"); //notification["send_after"] = System.DateTime.Now.ToUniversalTime().AddMinutes(5).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); Debug.Log(oneSignalDebugMessage); }, (responseFailure) => { oneSignalDebugMessage = "Notification failed to post:\n" + Json.Serialize(responseFailure); Debug.Log(oneSignalDebugMessage); }); }
protected virtual void SendNotification(string message, int addedHours, int addedMinutes, int addedSeconds) { OneSignal.IdsAvailable((userId, token) => { if (token == null) { return; } extraMessage = "Waiting to get a OneSignal userId. Uncomment OneSignal. SetLogLevel in the 'Start' method if it hangs here to debug the issue."; var localTime = System.DateTime.Now.ToUniversalTime(); var notification = new Dictionary <string, object>(); notification["contents"] = new Dictionary <string, string>() { { "en", string.Format("{0} ({1}:{2}:{3})", message, localTime.Hour.ToString("00"), localTime.Minute.ToString("00"), localTime.Second.ToString("00")) } }; // Send notification to this device. notification["include_player_ids"] = new List <string>() { userId }; // Example of scheduling a notification in the future. notification["send_after"] = localTime.AddSeconds(addedSeconds).AddMinutes(addedMinutes).AddHours(addedHours).ToString("U"); extraMessage = "Posting test notification now."; OneSignal.PostNotification(notification, (responseSuccess) => { extraMessage = "Notification posted successful! Delayed by a predetermined time amount to give you time to press the home button to see a notification vs an in-app alert.\n" + Json.Serialize(responseSuccess); }, (responseFailure) => { extraMessage = "Notification failed to post:\n" + Json.Serialize(responseFailure); }); OneSignal.ClearOneSignalNotifications(); }); }
public void OnClick_Logout() { PlayerPrefs.DeleteAll(); OneSignal.ClearOneSignalNotifications(); SceneManager.LoadScene("Initialization"); }