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()); }
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++); }; }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { OneSignal.NotificationReceived exampleNotificationReceivedDelegate = delegate(OSNotification notification) { try { System.Console.WriteLine("OneSignal Notification Received: {0}", notification.payload.body); Dictionary <string, object> additionalData = notification.payload.additionalData; if (additionalData.Count > 0) { System.Console.WriteLine("additionalData: {0}", additionalData); } } catch (System.Exception e) { System.Console.WriteLine(e.StackTrace); } }; // Notification Opened Delegate OneSignal.NotificationOpened exampleNotificationOpenedDelegate = delegate(OSNotificationOpenedResult result) { try { System.Console.WriteLine("OneSignal Notification opened: {0}", result.notification.payload.body); Dictionary <string, object> additionalData = result.notification.payload.additionalData; List <Dictionary <string, object> > actionButtons = result.notification.payload.actionButtons; if (additionalData.Count > 0) { System.Console.WriteLine("additionalData: {0}", additionalData); } if (actionButtons.Count > 0) { System.Console.WriteLine("actionButtons: {0}", actionButtons); } } catch (System.Exception e) { System.Console.WriteLine(e.StackTrace); } }; // Initialize OneSignal OneSignal.StartInit("b2f7f966-d8cc-11e4-bed1-df8f05be55ba") .HandleNotificationReceived(exampleNotificationReceivedDelegate) .HandleNotificationOpened(exampleNotificationOpenedDelegate) .InFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification) .Settings(new Dictionary <string, bool> { { OneSignal.kOSSettingsKeyAutoPrompt, true }, { OneSignal.kOSSettingsKeyInAppLaunchURL, false } }) .EndInit(); OneSignal.IdsAvailable((playerID, pushToken) => { try { System.Console.WriteLine("Player ID: " + playerID); if (pushToken != null) { System.Console.WriteLine("Push Token: " + pushToken); } } catch (System.Exception e) { System.Console.WriteLine(e.StackTrace); } }); return(true); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); OneSignal.NotificationReceived exampleNotificationReceivedDelegate = delegate(OSNotification notification) { try { System.Console.WriteLine("OneSignal Notification Received:\nMessage: {0}", notification.payload.body); Dictionary <string, object> additionalData = notification.payload.additionalData; if (additionalData.Count > 0) { System.Console.WriteLine("additionalData: {0}", additionalData); } } catch (System.Exception e) { System.Console.WriteLine(e.StackTrace); } }; // Notification Opened Delegate OneSignal.NotificationOpened exampleNotificationOpenedDelegate = delegate(OSNotificationOpenedResult result) { try { System.Console.WriteLine("OneSignal Notification opened:\nMessage: {0}", result.notification.payload.body); Dictionary <string, object> additionalData = result.notification.payload.additionalData; if (additionalData.Count > 0) { System.Console.WriteLine("additionalData: {0}", additionalData); } List <Dictionary <string, object> > actionButtons = result.notification.payload.actionButtons; if (actionButtons.Count > 0) { System.Console.WriteLine("actionButtons: {0}", actionButtons); } } catch (System.Exception e) { System.Console.WriteLine(e.StackTrace); } }; // Initialize OneSignal OneSignal.StartInit("b2f7f966-d8cc-11e4-bed1-df8f05be55ba") .HandleNotificationReceived(exampleNotificationReceivedDelegate) .HandleNotificationOpened(exampleNotificationOpenedDelegate) .InFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification) .Settings(new Dictionary <string, bool> { { OneSignal.kOSSettingsKeyAutoPrompt, true }, { OneSignal.kOSSettingsKeyInAppLaunchURL, false } }) .EndInit(); OneSignal.IdsAvailable((playerID, pushToken) => { try { System.Console.WriteLine("Player ID: " + playerID); if (pushToken != null) { System.Console.WriteLine("Push Token: " + pushToken); } } catch (System.Exception e) { System.Console.WriteLine(e.StackTrace); } }); // 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++); }; }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); // Notification Receive Delegate OneSignal.NotificationReceived exampleNotificationReceivedDelegate = delegate(OSNotification notification) { try { System.Console.WriteLine("OneSignal Notification Received:\nMessage: {0}", notification.payload.body); Dictionary <string, object> additionalData = notification.payload.additionalData; if (additionalData.Count > 0) { System.Console.WriteLine("additionalData: {0}", additionalData); } } catch (System.Exception e) { System.Console.WriteLine(e.StackTrace); } }; // Notification Opened Delegate OneSignal.NotificationOpened exampleNotificationOpenedDelegate = delegate(OSNotificationOpenedResult result) { try { System.Console.WriteLine("OneSignal Notification opened:\nMessage: {0}", result.notification.payload.body); Dictionary <string, object> additionalData = result.notification.payload.additionalData; if (additionalData.Count > 0) { System.Console.WriteLine("additionalData: {0}", additionalData); } List <Dictionary <string, object> > actionButtons = result.notification.payload.actionButtons; if (actionButtons.Count > 0) { System.Console.WriteLine("actionButtons: {0}", actionButtons); } } catch (System.Exception e) { System.Console.WriteLine(e.StackTrace); } }; // Initialize OneSignal OneSignal.StartInit("f8b5ffe8-33e3-47de-b0bc-c7fe05325f80", "211973902557") .HandleNotificationReceived(exampleNotificationReceivedDelegate) .HandleNotificationOpened(exampleNotificationOpenedDelegate) .EndInit(); global::Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new App()); }