public void Init() { if (!OneSignalInit) { switch (Application.bundleIdentifier) { case "com.monsmile.projecth.ios.dev": case "com.monsmile.herocry.ios.dev": OneSignal.Init("b4c915a0-4494-4d6e-8ade-efce0a40ad01", string.Empty, HandleNotification); break; case "com.monsmile.projecth.ios": OneSignal.Init("517412e4-b97d-4b24-9681-9f4dfc26fa00", string.Empty, HandleNotification); break; case "com.monsmile.projecth.android.dev": OneSignal.Init("b4c915a0-4494-4d6e-8ade-efce0a40ad01", "357018248098", HandleNotification, true); OneSignal.EnableNotificationsWhenActive(false); break; case "com.monsmile.projecth.android.test": OneSignal.Init("517412e4-b97d-4b24-9681-9f4dfc26fa00", "725610003103", HandleNotification); OneSignal.EnableNotificationsWhenActive(false); break; } OneSignalInit = true; } ResetBadgeNumber(); OneSignal.SetSubscription(true); OneSignal.GetIdsAvailable(SetPushInfo); }
public void Suscribirse() { OneSignal.SetSubscription(true); BtnYes.SetActive(true); BtnNo.SetActive(false); PlayerPrefs.SetInt("Subs", 1); }
public void CheckExternalRegister(string refresh, string expires, string email) { Headers = new List <Header>() { new Header("Authorization", " Bearer " + userToken.Token) }; if (string.IsNullOrEmpty(refresh)) { Canvaser.Instance.RegistrationPanel.ExternalRegistration(email); } else { LocalUser = false; var seconds = int.Parse(Regex.Replace(expires, "\\D", string.Empty)); PlayerPrefs.SetString("provider_gosha", LoginProvider); PlayerPrefs.SetString("refresh_token_gosha", refresh); PlayerPrefs.SetString("refresh_expires_in_gosha", DateTime.Now.AddSeconds(seconds).ToString()); OneSignal.SetSubscription(true); OneSignal.SyncHashedEmail(email); Canvaser.Instance.LoginPanel.SetActive(false); GetUserInfoAsync(); Canvaser.Instance.MainMenu.SetActive(true); AdsManager.Instance.OnAdsDownloaded += () => Canvaser.Instance.CloseLoading(); AdsManager.Instance.GetAds(Canvaser.Instance.ADSPanel.txt, Canvaser.Instance.ADSPanel.img); } }
public void LogOut() { PlayerPrefs.DeleteKey("refresh_token_gosha"); PlayerPrefs.DeleteKey("refresh_expires_in_gosha"); PlayerPrefs.DeleteKey("provider_gosha"); PlayerPrefs.DeleteKey("CurrentSuit"); PlayerPrefs.DeleteKey("token_gosha"); PlayerPrefs.DeleteKey("token_expires_in_gosha"); PlayerController.Instance.TakeOffSuits(); OneSignal.SetSubscription(false); FB.LogOut(); if (OK.IsInitialized) { OK.Logout(); } VK.LogOut(); Headers = new List <Header>(); userToken = null; User = new UserInfoModel(); LocalUser = true; Canvaser.Instance.SetAllIceCreams(User.IceCream); Canvaser.Instance.SetNotifications(User); GameController.Instance.ResetBonusesTime(); Canvaser.Instance.SBonuses.ResetStartBonuses(); }
public void RegisterForRemoteNotifications() { if (!m_registeredForOneSignalPushNotifications) { m_registeredForOneSignalPushNotifications = true; OneSignal.RegisterForPushNotifications(); OneSignal.SetSubscription(true); } }
/// <summary> /// Unregister for all remote notifications received via Push Notification service. /// </summary> /// <remarks> /// \note Apps unregistered through this method can always re-register. /// </remarks> public virtual void UnregisterForRemoteNotifications() { #if (USES_ONE_SIGNAL && !UNITY_EDITOR) if (m_registeredForOneSignalPushNotifications) { m_registeredForOneSignalPushNotifications = false; OneSignal.SetSubscription(false); } #endif }
/// <summary> /// Unregister for all remote notifications received via Push Notification service. /// </summary> /// <remarks> /// \note Apps unregistered through this method can always re-register. /// </remarks> public void UnregisterForRemoteNotifications() { #if (!USES_ONE_SIGNAL || UNITY_EDITOR) m_platform.UnregisterForRemoteNotifications(); #else if (m_registeredForOneSignalPushNotifications) { m_registeredForOneSignalPushNotifications = false; OneSignal.SetSubscription(false); } #endif }
private void WorkWithStatusInfo() { var allowed = GetStatusInfo().allowed; if (allowed) { _sceneLoader.LoadMainScene(); } else { OneSignal.SetSubscription(false); Screen.orientation = ScreenOrientation.Landscape; _sceneLoader.LoadSlotsScene(); } }
/// <summary> /// /// </summary> /// <param name="intent"></param> /// <param name="flags"></param> /// <param name="startId"></param> /// <returns></returns> public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { Log.Debug("OneSignalNotificationBackgroundService", "on start"); IsServiceRunning = true; new Task(() => { //Connect to OneSignal OneSignal.Init(this, "1077123816365", "ee8851b0-f171-4de0-b86b-74ef18eefa02", new NotificationOpenedHandler(), new NotificationReceivedHandler(this)); OneSignal.SetSubscription(true); OneSignal.IdsAvailable(new IdsAvailableHandler()); }); return(StartCommandResult.Sticky); }
private void OneSignal_permissionObserver(OSPermissionStateChanges stateChanges) { if (stateChanges.from.status == OSNotificationPermission.NotDetermined) { if (stateChanges.to.status == OSNotificationPermission.Authorized) { Debug.Log("Thanks for accepting notifications!"); OneSignal.SetSubscription(true); PostNotification(OneSignal.GetPermissionSubscriptionState().subscriptionStatus.userId); } else if (stateChanges.to.status == OSNotificationPermission.Denied) { Debug.Log("Notifications not accepted. You can turn them on later under your device settings."); } } }
public void PostNotification(string ID) { print("Post Notification Called"); if (SecurePlayerPrefs.GetInt("ActiveMessage", 0) == 0) { if (ID != null) { print(ID); var notification = new Dictionary <string, object>(); notification["contents"] = new Dictionary <string, string>() { { "en", "Your stars are ready to be collected" } }; notification["headings"] = new Dictionary <string, string>() { { "en", "Free Stars!🌟" } }; notification["include_player_ids"] = new List <string>() { ID }; // Example of scheduling a notification in the future. notification["send_after"] = System.DateTime.Now.ToUniversalTime().AddHours(12).ToString("U"); OneSignal.PostNotification(notification, (responseSuccess) => { print("Success"); 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); SecurePlayerPrefs.SetInt("ActiveMessage", 1); }, (responseFailure) => { print("Failure"); oneSignalDebugMessage = "Notification failed to post:\n" + Json.Serialize(responseFailure); }); } else { print("User ID not found"); OneSignal.SetSubscription(true); } } else { print("Message already being sent"); } }
/// <summary> /// Registers to receive remote notifications via Push Notification service. /// </summary> /// <description> /// Call this method to initiate the registration process with Push Notification service. /// When registration process completes, <see cref="DidFinishRegisterForRemoteNotificationEvent"/> is fired. /// If registration succeeds, then you should pass device token to the server you use to generate remote notifications. /// </description> /// <remarks> /// \note If you want your app’s remote notifications to display alerts, play sounds etc you must call the <see cref="RegisterNotificationTypes"/> method before registering for remote notifications. /// </remarks> public void RegisterForRemoteNotifications() { #if (!USES_ONE_SIGNAL || UNITY_EDITOR) m_platform.RegisterForRemoteNotifications(); #else if (!m_registeredForOneSignalPushNotifications) { m_registeredForOneSignalPushNotifications = true; OneSignal.RegisterForPushNotifications(); OneSignal.SetSubscription(true); OneSignal.IdsAvailable(DidReceiveIDsAvaialble); //DidRegisterRemoteNotification(null); } #endif }
public void GetTokenAsync(string email, string password) { LoginBtn.interactable = false; CoroutineManager.SendRequest(LoginUrl, string.Format("username={0}&password={1}&grant_type=password", email, password), (AccessToken token) => { Extensions.RemoveJsonData(DataType.UserInfo); LocalUser = false; userToken = token; PlayerPrefs.SetString("refresh_token_gosha", userToken.RefreshToken); PlayerPrefs.SetString("refresh_expires_in_gosha", DateTime.Now.AddSeconds(userToken.RefreshExpireIn).ToString()); PlayerPrefs.SetString("token_gosha", userToken.Token); PlayerPrefs.SetString("token_expires_in_gosha", DateTime.Now.AddSeconds(userToken.TokenExpiresIn).ToString()); OneSignal.SetSubscription(true); OneSignal.SyncHashedEmail(userToken.Email); LoginCanvas.Instance.EnableWarning(false); Debug.Log(userToken.Token); LoginCanvas.Instance.Enable(false); Headers = new List <Header>() { new Header("Authorization", " Bearer " + userToken.Token) }; GetUserInfoAsync(); //AdsManager.Instance.OnAdsDownloaded += () => Canvaser.Instance.ADSPanel.OpenAds(); AdsManager.Instance.OnAdsDownloaded += () => Canvaser.Instance.CloseLoading(); AdsManager.Instance.GetAds(Canvaser.Instance.ADSPanel.txt, Canvaser.Instance.ADSPanel.img); }, (response) => { LoginCanvas.Instance.EnableWarning(true); }, finallyMethod: () => { LoginBtn.interactable = true; }); }
/// <summary> /// Registers to receive remote notifications via Push Notification service. /// </summary> /// <description> /// Call this method to initiate the registration process with Push Notification service. /// When registration process completes, <see cref="DidFinishRegisterForRemoteNotificationEvent"/> is fired. /// If registration succeeds, then you should pass device token to the server you use to generate remote notifications. /// </description> /// <remarks> /// \note If you want your app’s remote notifications to display alerts, play sounds etc you must call the <see cref="RegisterNotificationTypes"/> method before registering for remote notifications. /// </remarks> public void RegisterForRemoteNotifications() { #if (!USES_ONE_SIGNAL || UNITY_EDITOR) m_platform.RegisterForRemoteNotifications(); #else if (!m_registeredForOneSignalPushNotifications) { m_registeredForOneSignalPushNotifications = true; OneSignal.RegisterForPushNotifications(); OneSignal.SetSubscription(true); #if NP_DEBUG Debug.Log("[NotificationService] One Signal Library don't give access to device token. It handles internally and passes to its server."); #endif DidRegisterRemoteNotification(null); } #endif }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState, Resource.Layout.ListSeekiosLayout, true); var drawerToggle = new ActionBarDrawerToggle(this, DrawerNavigation, ToolbarPage, Resource.String.open_drawer, Resource.String.close_drawer); DrawerNavigation.SetDrawerListener(drawerToggle); drawerToggle.SyncState(); _dispatcher = (ServiceLocator.Current.GetInstance <IDispatchOnUIThread>() as DispatchService); GetObjectsFromView(); SetDataToView(); CurrentActivity = this; // Connect to OneSignal OneSignal.Init(this, "1077123816365" , "ee8851b0-f171-4de0-b86b-74ef18eefa02" , new NotificationOpenedHandler() , new NotificationReceivedHandler(this)); OneSignal.SetSubscription(true); OneSignal.IdsAvailable(new IdsAvailableHandler()); // Display popup if the new reload credit is available App.Locator.ListSeekios.PopupRelaodCreditMonthly(); // Display a popup if the notification push are not registered App.Locator.ListSeekios.PopupNotificationNotAvailable(() => { using (var intent = new Android.Content.Intent(Android.Content.Intent.ActionView , Android.Net.Uri.Parse(App.TutorialNotificationLink))) { StartActivity(intent); } }); // Register to SignalR App.Locator.ListSeekios.SubscribeToSignalR(); // Get the uidDevice (required by webservice for identify the sender of the broadcast) App.UidDevice = Helper.DeviceInfoHelper.GetDeviceUniqueId(this); }
public void GetTokenByRefreshAsync(string refreshToken) { CoroutineManager.SendRequest(LoginUrl, string.Format("refresh_token={0}&grant_type=refresh_token", refreshToken), (AccessToken token) => { LocalUser = false; userToken = token; OneSignal.SetSubscription(true); OneSignal.SyncHashedEmail(userToken.Email); PlayerPrefs.SetString("refresh_token_gosha", userToken.RefreshToken); PlayerPrefs.SetString("refresh_expires_in_gosha", DateTime.Now.AddSeconds(userToken.RefreshExpireIn).ToString()); PlayerPrefs.SetString("token_gosha", userToken.Token); PlayerPrefs.SetString("token_expires_in_gosha", DateTime.Now.AddSeconds(userToken.TokenExpiresIn).ToString()); LoginCanvas.Instance.EnableWarning(false); Debug.Log(userToken.Token); LoginCanvas.Instance.Enable(false); Headers = new List <Header>() { new Header("Authorization", " Bearer " + userToken.Token) }; GetUserInfoAsync(); //AdsManager.Instance.OnAdsDownloaded += () => Canvaser.Instance.ADSPanel.OpenAds(); AdsManager.Instance.OnAdsDownloaded += () => Canvaser.Instance.CloseLoading(); AdsManager.Instance.GetAds(Canvaser.Instance.ADSPanel.txt, Canvaser.Instance.ADSPanel.img); }, (response) => { //LoginCanvas.Instance.EnableWarning(true); Canvaser.Instance.CloseLoading(); }); }
/// <summary> /// Deconnection of the user /// </summary> private void DeconnectionLayout_Click(object sender, EventArgs e) { RunOnUiThread(async() => { LoadingLayout.Visibility = ViewStates.Visible; // Delete the device from the database if (App.CurrentUserEnvironment.Device != null) { if (await App.Locator.Login.Disconnect(App.CurrentUserEnvironment.Device.UidDevice) == 1) { // Stop notification from OneSignal OneSignal.SetSubscription(false); // Go to login page App.Locator.LeftMenu.GoToLogin(); if (!IsFinishing) //cf https://rink.hockeyapp.net/manage/apps/323214/app_versions/27/crash_reasons/151001492 { //LoginManager.Instance.LogOut(); //facebook disconnection Finish(); } } } LoadingLayout.Visibility = ViewStates.Gone; }); }
public virtual void SetSubscribed(bool value) { OneSignal.SetSubscription(value); }
public void SetSubscription(bool enable) { OneSignal.SetSubscription(enable); }