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 {ons_id}");
OneSignal.Debug.LogLevel = LogLevel.Debug;
OneSignal.Initialize(ons_id);
RequestPermissionToAllowNotifications();
}
///
/// This function is used to Request permission to Allow Notifications for the app
///
private void RequestPermissionToAllowNotifications()
{
Debug.Log("Requesting permission to allow notifications");
OneSignal.Notifications.RequestPermissionAsync(true);
}
}