public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { // Notification Opened Delegate OneSignal.NotificationOpened exampleNotificationOpenedDelegate = delegate(string message, Dictionary <string, object> additionalData, bool isActive) { try { System.Console.WriteLine("OneSignal Notification opened:\nMessage: {0}", message); if (additionalData != null) { if (additionalData.ContainsKey("customKey")) { System.Console.WriteLine("customKey: {0}", additionalData ["customKey"]); } System.Console.WriteLine("additionalData: {0}", additionalData); } } catch (System.Exception e) { System.Console.WriteLine(e.StackTrace); } }; // Initialize OneSignal OneSignal.Init(exampleNotificationOpenedDelegate); return(true); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); c = this; global::Xamarin.Forms.Forms.Init(this, bundle); Xamarin.Forms.DependencyService.Register <Dependencies_Android>(); ImageCircleRenderer.Init(); OneSignal.NotificationOpened exampleNotificationOpenedDelegate = delegate(string message, System.Collections.Generic.Dictionary <string, object> additionalData, bool isActive) { try { MainPage.openEvent = (int)additionalData["eventid"]; } catch (System.Exception e) { System.Console.WriteLine(e.StackTrace); } }; OneSignal.Init(exampleNotificationOpenedDelegate); LoadApplication(new App()); }
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); }
protected override void OnLaunched(LaunchActivatedEventArgs e) { OneSignal.Init("c75f3c32-9afa-4a78-b425-edc6d4f9be68", e, notificationOpened); Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { } Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), e.Arguments); } Window.Current.Activate(); } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif OneSignal.Init("b2f7f966-d8cc-11e4-bed1-df8f05be55ba", e, notificationOpened); Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 1; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // Removes the turnstile navigation for startup. if (rootFrame.ContentTransitions != null) { this.transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { this.transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); }
// managed platform functionality public void OneSignalInitialize_managed(string appId) { OneSignal.Init(appId, (message, additionalData, isActive) => { m_Native.CLR_TO_MARM_NotificationReceivedCallback((message == null) ? "" : message, (additionalData == null) ? "" : JObject.FromObject(additionalData).ToString(), isActive); }); }
void Start() { // Should only be called once when your app is loaded. // OneSignal.Init(OneSignal_AppId, GoogleProjectNumber, NotificationReceivedHandler(optional)); OneSignal.Init("54a71637-0755-4b10-9d21-f91659637a36", "28159365108", HandleNotification); // Shows a Native iOS/Android alert dialog when the user is in your app when a notification comes in. OneSignal.EnableInAppAlertNotification(true); }
protected virtual void InitialiseOneSignalService() { // Initialise One Signal service OneSignalServiceSettings _oneSignalSettings = NPSettings.AddonServicesSettings.OneSignalService; OneSignal.Init(_oneSignalSettings.AppID, _oneSignalSettings.GoogleProjectNumber, DidReceiveOneSignalNotification, false); }
void Start() { extraMessage = null; // Enable line below to debug issues with setuping OneSignal. (logLevel, visualLogLevel) //OneSignal.SetLogLevel(OneSignal.LOG_LEVEL.INFO, OneSignal.LOG_LEVEL.INFO); // The only required method you need to call to setup OneSignal to recieve push notifications. // Call before using any other methods on OneSignal. // Should only be called once when your game is loaded. // OneSignal.Init(OneSignal_AppId, GoogleProjectNumber, NotificationReceivedHandler(optional)); OneSignal.Init("b2f7f966-d8cc-11e4-bed1-df8f05be55ba", "703322744261", HandleNotification); }
/// <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); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); Xamarin.Forms.DependencyService.Register <Dependencies_iOS>(); ImageCircleRenderer.Init(); UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false); LoadApplication(new App()); OneSignal.Init((message, additionalData, isActivity) => { MainPage.openEvent = (int)additionalData["eventid"]; }); return(base.FinishedLaunching(app, options)); }
/// <summary> /// Initializes this instance. /// </summary> public bool Initialize(bool useNotifs) { #if !UNITY_EDITOR if (useNotifs) { // Enable line below to enable logging if you are having issues // setting up OneSignal. (logLevel, visualLogLevel) //OneSignal.SetLogLevel(OneSignal.LOG_LEVEL.INFO, OneSignal.LOG_LEVEL.INFO); OneSignal.Init("ed4f54c2-6e47-11e5-9777-bb1a46033f58", "518470690122", HandleNotification); } #endif // Set the initialized flag m_isInitialized = true; return(true); }
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); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Notification Opened Delegate OneSignal.NotificationOpened exampleNotificationOpenedDelegate = delegate(string message, Dictionary <string, object> additionalData, bool isActive) { try { System.Console.WriteLine("OneSignal Notification opened:\nMessage: {0}", message); if (additionalData != null) { if (additionalData.ContainsKey("customKey")) { System.Console.WriteLine("customKey: {0}", additionalData ["customKey"]); } System.Console.WriteLine("additionalData: {0}", additionalData); } } catch (System.Exception e) { System.Console.WriteLine(e.StackTrace); } }; // Initialize OneSignal OneSignal.Init(exampleNotificationOpenedDelegate); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button> (Resource.Id.myButton); button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); }; }
// Use this for initialization void Start() { OneSignal.Init(appData.oneSignalId, "920809726025", HandleNotification); menuData = new MenuData(); langManager = LanguageManager.Instance; LanguageManager.Instance.OnChangeLanguage += OnLanguageChanged; switch (Application.systemLanguage) { case SystemLanguage.Russian: langManager.ChangeLanguage("ru"); break; case SystemLanguage.Finnish: langManager.ChangeLanguage("fi"); break; case SystemLanguage.English: langManager.ChangeLanguage("en"); break; default: langManager.ChangeLanguage("ru"); break; } //StartCoroutine (SendDeviceInfo ()); StartCoroutine(waitForDownloadAppData()); StartCoroutine(waitForDownloadResourceData()); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (Debugger.IsAttached) { DebugSettings.EnableFrameRateCounter = false; } #endif var titleBar = ApplicationView.GetForCurrentView().TitleBar; if (titleBar != null) { titleBar.ForegroundColor = titleBar.InactiveForegroundColor = (Color)Resources["RohBotTitleBarForegroundColor"]; titleBar.ButtonForegroundColor = titleBar.ButtonInactiveForegroundColor = titleBar.ButtonHoverForegroundColor = titleBar.ButtonPressedForegroundColor = (Color)Resources["RohBotTitleBarButtonForegroundColor"]; titleBar.BackgroundColor = (Color)Resources["RohBotTitleBarBackgroundColor"]; titleBar.InactiveBackgroundColor = (Color)Resources["RohBotTitleBarBackgroundInactiveColor"]; titleBar.ButtonBackgroundColor = (Color)Resources["RohBotTitleBarButtonBackgroundColor"]; titleBar.ButtonHoverBackgroundColor = (Color)Resources["RohBotTitleBarButtonBackgroundHoverColor"]; titleBar.ButtonPressedBackgroundColor = (Color)Resources["RohBotTitleBarButtonBackgroundPressedColor"]; titleBar.ButtonInactiveBackgroundColor = (Color)Resources["RohBotTitleBarButtonBackgroundInactiveColor"]; } Client.Instance.SysMessageReceived -= Client_OnSysMessageReceived; Client.Instance.SysMessageReceived += Client_OnSysMessageReceived; StartConnectionTask(); OneSignal.Init("97f9b9a8-dcd0-46a0-a6f3-c61600d38cd3", e.Arguments); Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.Loaded += async(sender, args) => { if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0)) { var statusBar = StatusBar.GetForCurrentView(); await statusBar.HideAsync(); } }; rootFrame.Navigated += (sender, args) => { var navManager = SystemNavigationManager.GetForCurrentView(); var pageType = args.SourcePageType; if (pageType == typeof(LoginPage) || pageType == typeof(AppShell)) { rootFrame.BackStack.Clear(); navManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } else { var backButtonVisibility = rootFrame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = backButtonVisibility; } }; rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(Settings.LoggedIn.Value ? typeof(AppShell) : typeof(LoginPage)); } // Ensure the current window is active Window.Current.Activate(); } SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; }
/// <summary> /// Вызывается при обычном запуске приложения пользователем. Будут использоваться другие точки входа, /// если приложение запускается для открытия конкретного файла, отображения /// результатов поиска и т. д. /// </summary> /// <param name="e">Сведения о запросе и обработке запуска.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif OneSignal.Init("2baab644-8886-4090-82ea-8aac8dfcb9ac", e); if (App.WebService.IsInternetAvailable()) { WebResponse response = await WebService.AboutContentJsonResponse(); var json = await Deserializer.Execute <AboutAnswer>(response.GetResponseStream()); Debug.WriteLine(json.SocialLinkYb == null); var model = await json.GetModel(); if (AppRepository.AboutPage.Content == null) { AppRepository.AboutPage.Insert(model); } if (AppRepository.AboutPage.Content.Utd != model.Utd) { AppRepository.AboutPage.UpdatePageContent(model); } } Frame rootFrame = Window.Current.Content as Frame; // Не повторяйте инициализацию приложения, если в окне уже имеется содержимое, // только обеспечьте активность окна if (rootFrame == null) { // Создание фрейма, который станет контекстом навигации, и переход к первой странице rootFrame = new Frame(); // TODO: Измените это значение на размер кэша, подходящий для вашего приложения rootFrame.CacheSize = 0; // Задайте язык по умолчанию rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Загрузить состояние из ранее приостановленного приложения } // Размещение фрейма в текущем окне Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // Удаляет турникетную навигацию для запуска. if (rootFrame.ContentTransitions != null) { this.transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { this.transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; // Если стек навигации не восстанавливается для перехода к первой странице, // настройка новой страницы путем передачи необходимой информации в качестве параметра // навигации if (AppRepository.User.Data == null) { if (!rootFrame.Navigate(typeof(RegistrationPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } else { if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } } // Обеспечение активности текущего окна Window.Current.Activate(); }
//-------------------------------------- // PUBLIC METHODS //-------------------------------------- public void InitOneSignalNotifications() { #if ONE_SIGNAL_ENABLED OneSignal.Init(AndroidNativeSettings.Instance.OneSignalAppID, AndroidNativeSettings.Instance.GCM_SenderId, HandleNotification); #endif }
//-------------------------------------- // PUBLIC METHODS //-------------------------------------- public void InitOneSignalNotifications() { OneSignal.Init(AndroidNativeSettings.Instance.GameThriveAppID, AndroidNativeSettings.Instance.GCM_SenderId, HandleNotification); }
protected override void OnNavigatedTo(NavigationEventArgs navEventArgs) { base.OnNavigatedTo(navEventArgs); OneSignal.Init("b2f7f966-d8cc-11e4-bed1-df8f05be55ba", ReceivedNotification); }
public static void Init(string appId, string launchArgs, OneSignal.NotificationReceived inNotificationDelegate = null) { OneSignal.Init(appId, launchArgs, inNotificationDelegate, new ExternalInitCordovaInternal()); }
public void EndInit() { OneSignal.Init(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 1; Xamarin.Forms.Forms.Init(e); Xamarin.Forms.DependencyService.Register <Dependencies_WinPhone>(); ImageCircleRenderer.Init(); WindowsRuntimeResourceManager.PatchResourceManagersInAssembly(typeof(Resx.AppResources)); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } var uris = new List <Uri>(); for (int i = 0; i < 5; i++) { uris.Add(new Uri("http://" + Other.Other.GetBackendUrl() + "notifications/tiles/tile.php" + Other.Other.GetFinalUrl() + "&tile=" + i)); } TileUpdater LiveTileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); LiveTileUpdater.Clear(); LiveTileUpdater.EnableNotificationQueue(true); LiveTileUpdater.StartPeriodicUpdateBatch(uris, PeriodicUpdateRecurrence.Daily); BadgeUpdater BadgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); BadgeUpdater.Clear(); BadgeUpdater.StartPeriodicUpdate(new Uri("http://" + Other.Other.GetBackendUrl() + "notifications/tiles/badge.php" + Other.Other.GetFinalUrl()), PeriodicUpdateRecurrence.Daily); string colorPrimary = Other.Other.GetColorPrimary(); byte a = byte.Parse(colorPrimary.Substring(1, 2), NumberStyles.HexNumber); byte r = byte.Parse(colorPrimary.Substring(3, 2), NumberStyles.HexNumber); byte g = byte.Parse(colorPrimary.Substring(5, 2), NumberStyles.HexNumber); byte b = byte.Parse(colorPrimary.Substring(7, 2), NumberStyles.HexNumber); StatusBar.GetForCurrentView().ForegroundColor = Colors.White; StatusBar.GetForCurrentView().BackgroundColor = Color.FromArgb(a, r, g, b); StatusBar.GetForCurrentView().BackgroundOpacity = 1; OneSignal.Init(Other.Other.GetOneSignalAppId(), e, (message, additionalData, isActivity) => { if (additionalData.ContainsKey("eventid")) { GDG_SP.MainPage.openEvent = int.Parse(additionalData["eventid"]); } }); // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // Removes the turnstile navigation for startup. if (rootFrame.ContentTransitions != null) { this.transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { this.transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); }