You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.0 KiB
C#
44 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using OneSignalSDK;
|
|
using OneSignalSDK.Debug.Models;
|
|
using UnityEngine;
|
|
|
|
public class OSNInitializer : MonoBehaviour
|
|
{
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
Invoke(nameof(InitializeOSN),2f);
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeOSN()
|
|
{
|
|
string ons_id = "";
|
|
#if UNITY_ANDROID
|
|
ons_id = GameConstants.OSN_Android;
|
|
#elif UNITY_IOS
|
|
ons_id = GameConstants.OSN_iOS;
|
|
#endif
|
|
|
|
Debug.Log($"Initializing with appId <b>{ons_id}</b>");
|
|
OneSignal.Debug.LogLevel = LogLevel.Debug;
|
|
OneSignal.Initialize(ons_id);
|
|
RequestPermissionToAllowNotifications();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// This function is used to Request permission to Allow Notifications for the app
|
|
/// </summary>
|
|
private void RequestPermissionToAllowNotifications()
|
|
{
|
|
Debug.Log("Requesting permission to allow notifications");
|
|
OneSignal.Notifications.RequestPermissionAsync(true);
|
|
}
|
|
|
|
}
|