// Init - Only required method you call to setup OneSignal to receive push notifications. private static void Init() { #if ONESIGNAL_PLATFORM if (oneSignalPlatform != null || builder == null) { return; } #if __ANDROID__ oneSignalPlatform = new OneSignalAndroid(builder.appID, builder.googleProjectNumber, builder.displayOption, logLevel, visualLogLevel); #elif __IOS__ //extract settings bool autoPrompt = true, inAppLaunchURL = true; if (builder.iOSSettings != null) { if (builder.iOSSettings.ContainsKey(kOSSettingsKeyAutoPrompt)) { autoPrompt = builder.iOSSettings[kOSSettingsKeyAutoPrompt]; } if (builder.iOSSettings.ContainsKey(kOSSettingsKeyInAppLaunchURL)) { inAppLaunchURL = builder.iOSSettings[kOSSettingsKeyInAppLaunchURL]; } } oneSignalPlatform = new OneSignalIOS(builder.appID, autoPrompt, inAppLaunchURL, builder.displayOption, logLevel, visualLogLevel); #endif #endif }
// Init - Only required method you call to setup OneSignal to receive push notifications. public static void Init(NotificationOpened notificationOpenedDelegate, bool autoRegister) { //isAndroidPlatform = (CrossDeviceInfo.Current.Platform == Platform.Android); //isIOSPlatform = (CrossDeviceInfo.Current.Platform == Platform.iOS); //isOneSignalPlatform = true; //(isAndroidPlatform || isIOSPlatform); //supportsLogging = (isAndroidPlatform || isIOSPlatform); OneSignal.notificationOpenedDelegate = notificationOpenedDelegate; oneSignalPlatform = DependencyService.Get <OneSignalPlatform>(); initialized = true; #if ONESIGNAL_PLATFORM OneSignal.notificationOpenedDelegate = notificationOpenedDelegate; if (initialized) { return; } #if __ANDROID__ oneSignalPlatform = new OneSignalAndroid(logLevel, visualLevel); #elif __IOS__ oneSignalPlatform = new OneSignalIOS(autoRegister, logLevel, visualLevel); #endif initialized = true; #endif }
// Init - Only required method you call to setup OneSignal to recieve push notifications. // Call this on the first scene that is loaded. // appId = Your OneSignal AppId from onesignal.com // googleProjectNumber = Your Google Project Number that is only required for Android GCM pushes. // inNotificationDelegate = Calls this delegate when a notification is opened or one is received when the user is in your game. // autoRegister = Set false to delay the iOS accept notification system prompt. Defaults true. // You can then call RegisterForPushNotifications at a better point in your game to prompt them. public static void Init(string appId, string googleProjectNumber, NotificationReceived inNotificationDelegate, bool autoRegister) { #if !UNITY_EDITOR #if ONESIGNAL_PLATFORM if (initialized) { return; } #if UNITY_ANDROID oneSignalPlatform = new OneSignalAndroid(gameObjectName, googleProjectNumber, appId, logLevel, visualLogLevel); #elif UNITY_IPHONE oneSignalPlatform = new OneSignalIOS(gameObjectName, appId, autoRegister, logLevel, visualLogLevel); #elif UNITY_WP8 oneSignalPlatform = new OneSignalWP80(appId); #elif UNITY_WP_8_1 oneSignalPlatform = new OneSignalWPWNS(appId); #endif notificationDelegate = inNotificationDelegate; #if !UNITY_WP8 && !UNITY_WP_8_1 GameObject go = new GameObject(gameObjectName); go.AddComponent <OneSignal>(); DontDestroyOnLoad(go); #endif initialized = true; #endif #else print("Please run OneSignal on a device to see push notifications."); #endif }
// Init - Only required method you call to setup OneSignal to recieve push notifications. // Call this on the first scene that is loaded. // appId = Your OneSignal AppId from onesignal.com // googleProjectNumber = Your Google Project Number that is only required for Android GCM pushes. // inNotificationDelegate = Calls this delegate when a notification is opened or one is received when the user is in your game. // autoRegister = Set false to delay the iOS accept notification system prompt. Defaults true. // You can then call RegisterForPushNotifications at a better point in your game to prompt them. public static void Init(string appId, string googleProjectNumber, NotificationReceived inNotificationDelegate, bool autoRegister) { #if !UNITY_EDITOR #if ONESIGNAL_PLATFORM if (initialized) return; #if UNITY_ANDROID oneSignalPlatform = new OneSignalAndroid(gameObjectName, googleProjectNumber, appId, logLevel, visualLogLevel); #elif UNITY_IPHONE //oneSignalPlatform = new OneSignalIOS(gameObjectName, appId, autoRegister, logLevel, visualLogLevel); #elif UNITY_WP8 oneSignalPlatform = new OneSignalWP(appId); #endif notificationDelegate = inNotificationDelegate; #if !UNITY_WP8 GameObject go = new GameObject(gameObjectName); go.AddComponent<OneSignal>(); DontDestroyOnLoad(go); #endif initialized = true; #endif #else print("Please run OneSignal on a device to see push notifications."); #endif }
internal static OSSubscriptionStateChanges parseOSSubscriptionStateChanges(OneSignalPlatform platform, string stateChangesJSONString) { var stateChangesJson = Json.Deserialize(stateChangesJSONString) as Dictionary <string, object>; var permissionStateChanges = new OSSubscriptionStateChanges(); permissionStateChanges.to = platform.parseOSSubscriptionState(stateChangesJson["to"]); permissionStateChanges.from = platform.parseOSSubscriptionState(stateChangesJson["from"]); return(permissionStateChanges); }
internal static OSPermissionSubscriptionState parsePermissionSubscriptionState(OneSignalPlatform platform, string jsonStr) { var stateDict = Json.Deserialize(jsonStr) as Dictionary <string, object>; var state = new OSPermissionSubscriptionState(); state.permissionStatus = platform.parseOSPermissionState(stateDict["permissionStatus"]); state.subscriptionStatus = platform.parseOSSubscriptionState(stateDict["subscriptionStatus"]); return(state); }
internal static OSPermissionSubscriptionState ParsePermissionSubscriptionState(OneSignalPlatform platform, string jsonStr) { var stateDict = Json.Deserialize(jsonStr) as Dictionary <string, object>; var state = new OSPermissionSubscriptionState(); state.permissionStatus = platform.ParseOSPermissionState(stateDict["permissionStatus"]); state.subscriptionStatus = platform.ParseOSSubscriptionState(stateDict["subscriptionStatus"]); if (stateDict.ContainsKey("emailSubscriptionStatus")) { state.emailSubscriptionStatus = platform.ParseOSEmailSubscriptionState(stateDict["emailSubscriptionStatus"]); } return(state); }
private static void initIOS() { bool autoPrompt = true, inAppLaunchURL = true; if (builder.iOSSettings != null) { if (builder.iOSSettings.ContainsKey(kOSSettingsAutoPrompt)) { autoPrompt = builder.iOSSettings[kOSSettingsAutoPrompt]; } if (builder.iOSSettings.ContainsKey(kOSSettingsInAppLaunchURL)) { inAppLaunchURL = builder.iOSSettings[kOSSettingsInAppLaunchURL]; } } oneSignalPlatform = new OneSignalIOS(gameObjectName, builder.appID, autoPrompt, inAppLaunchURL, inFocusDisplayType, logLevel, visualLogLevel, requiresUserConsent); }
private static void Init() { #if !UNITY_EDITOR #if ONESIGNAL_PLATFORM if (oneSignalPlatform != null || builder == null) { return; } #if UNITY_ANDROID oneSignalPlatform = new OneSignalAndroid(gameObjectName, builder.googleProjectNumber, builder.appID, builder.displayOption, logLevel, visualLogLevel); #elif UNITY_IPHONE //extract settings bool autoPrompt = true, inAppAlerts = true, inAppLaunchURL = true; if (builder.displayOption == OSInFocusDisplayOption.None) { inAppAlerts = false; } if (builder.iOSSettings != null) { if (builder.iOSSettings.ContainsKey(kOSSettingsAutoPrompt)) { autoPrompt = builder.iOSSettings[kOSSettingsAutoPrompt]; } if (builder.iOSSettings.ContainsKey(kOSSettingsInAppLaunchURL)) { inAppLaunchURL = builder.iOSSettings[kOSSettingsInAppLaunchURL]; } } oneSignalPlatform = new OneSignalIOS(gameObjectName, builder.appID, autoPrompt, inAppAlerts, inAppLaunchURL, builder.displayOption, logLevel, visualLogLevel); #elif UNITY_WP_8_1 oneSignalPlatform = new OneSignalWPWNS(builder.appID); #endif #if !UNITY_WP_8_1 GameObject go = new GameObject(gameObjectName); go.AddComponent <OneSignal>(); DontDestroyOnLoad(go); #endif #endif #else print("Please run OneSignal on a device to see push notifications."); #endif }
private static void initWP81() { oneSignalPlatform = new OneSignalWPWNS(builder.appID); }
private static void initAndroid() { oneSignalPlatform = new OneSignalAndroid(gameObjectName, builder.googleProjectNumber, builder.appID, inFocusDisplayType, logLevel, visualLogLevel, requiresUserConsent); }