public override bool FinishedLaunching(UIApplication app, NSDictionary options) { if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } global::Xamarin.Forms.Forms.Init(); LoadApplication(new App()); return(base.FinishedLaunching(app, options)); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { var plist = NSUserDefaults.StandardUserDefaults; if (plist.BoolForKey("userLogin")) { //We are already authenticated, so go to the main tab bar controller; var tabBarController = GetViewController(MainStoryboard, "usuarioStoryBoard"); SetRootViewController(tabBarController, false); } else { //User needs to log in, so show the Login View Controlller var loginViewController = GetViewController(MainStoryboard, "MainNavigation"); SetRootViewController(loginViewController, false); } if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } //UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate(); return(true); }
public void RegisterDevice() { if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } }
// // 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) { Debug.WriteLine("App finished launching"); // Process any potential notification data from launch ProcessNotification(app.ApplicationState, options, true); // Register for Notifications if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } global::Xamarin.Forms.Forms.Init(); Xamarin.FormsMaps.Init(); ImageCircleRenderer.Init(); Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init(); LoadApplication(new App(IoC.Get <SimpleContainer>())); #if ENABLE_TEST_CLOUD Xamarin.Calabash.Start(); #endif return(base.FinishedLaunching(app, options)); }
public void InitRemoteNotifications() { if (_applicaitonContext.Settings.PushDisabled) { return; } if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.None, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { const UIRemoteNotificationType types = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(types); } }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { //Checking Notoification if (options != null) { if (options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey)) { UILocalNotification localNotification = options[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification; if (localNotification != null) { new UIAlertView(localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show(); UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0; } } if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey)) { NSDictionary remoteNotification = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary; if (remoteNotification != null) { // new UIAlertView( remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show(); } } } UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge; // register for remote notifications UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); //Register for remote notifications UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound); return(true); }
private async Task checkLogin() { iOSLoginManager loginManager = iOSLoginManager.Instance; bool shouldLogout = NSUserDefaults.StandardUserDefaults.BoolForKey("logout_preference"); if (shouldLogout) { loginManager.Logout(); NSUserDefaults.StandardUserDefaults.SetBool(false, "logout_preference"); } AccountManager acm = new AccountManager(); TravelerModel traveler = await acm.GetTravelerByEmail(loginManager.GetUsername()); if (traveler != null && !traveler.InformedConsent) { loginManager.Logout(); } if (!await loginManager.IsLoggedIn()) { PerformSegue("LoginSegue", this); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); if (CLLocationManager.LocationServicesEnabled) { mLocationManager.StartUpdatingLocation(); } await UpdateTripDisplays(); } }
// 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(); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } ImageCircleRenderer.Init(); CachedImageRenderer.Init(); Xamarin.FormsMaps.Init(); Rg.Plugins.Popup.Popup.Init(); IQKeyboardManager.SharedManager.Enable = true; IQKeyboardManager.SharedManager.EnableAutoToolbar = false; CurrentApp = new App(); LoadApplication(CurrentApp); OneSignal.Current.StartInit("0f3334c6-d6e1-46ab-9dc5-99d96b0e8c29").EndInit(); return(base.FinishedLaunching(app, options)); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init(); // followed steps from https://azure.microsoft.com/en-us/documentation/articles/xamarin-notification-hubs-ios-push-notification-apns-get-started/ // to configure notifications hub if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } return(true); }
public Task <string> GetPushNotificationChannelAsync() { _syncContext.Post(x => { // http://developer.xamarin.com/guides/cross-platform/application_fundamentals/notifications/ios/remote_notifications_in_ios/ if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } }, null); return(_getPushNotificationChannelTcs.Task); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { // Override point for customization after application launch. // If not required for your application you can safely delete this method // Register for push Notifications if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } return(true); }
// // 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) { #region 第三方套件/插件的初始化 ZXing.Net.Mobile.Forms.iOS.Platform.Init(); // Initialize the Azure Mobile Client SDK // http://stackoverflow.com/questions/24521355/azure-mobile-services-invalid-operation-exception-platform-specific-assembly-n Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init(); var rendererAssemblies = new[] { typeof(ImageCircleRenderer) }; //Console.WriteLine(PCLGlobalHelper.BaseAPIUrl); #endregion global::Xamarin.Forms.Forms.Init(); #region 要使用者允許接收通知之設定 // 系統版本是否大於或等於指定的主要和次要值. if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null ); app.RegisterUserNotificationSettings(notificationSettings); // 這能夠支援遠端通知,並要求推播註冊 UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } #endregion LoadApplication(new App(new iOSInitializer())); return(base.FinishedLaunching(app, options)); }
private void PrepareRemoteNotification() { try { if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0; UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } } catch (Exception ex) { } }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null ); UIApplication.SharedApplication.RegisterUserNotificationSettings(notificationSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); //new UIAlertView ("RegisterForRemoteNotifications", "RegisterForRemoteNotifications", null, "OK", null).Show (); } else { //==== register for remote notifications and get the device token // set what kind of notification types we want UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge; // register for remote notifications UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } return(true); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { var result = base.FinishedLaunching(app, options); AppCenter.Start(PrivateKeys.AppCenterAnalyticsAppSecret, typeof(Analytics), typeof(Crashes)); if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound, (granted, error) => { if (granted) { InvokeOnMainThread(UIApplication.SharedApplication.RegisterForRemoteNotifications); } }); } else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate(); return(result); }
// // 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) { Stormlion.ImageCropper.iOS.Platform.Init(); global::Xamarin.Forms.Forms.Init(); if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound, (granted, error) => { if (granted) { InvokeOnMainThread(UIApplication.SharedApplication.RegisterForRemoteNotifications); } }); } else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } LoadApplication(new App()); // return true; return(base.FinishedLaunching(app, options)); }
private void ProcessRemoteNotification(NSDictionary options, bool fromFinishedLaunching, UIApplicationState applicationState) { //Check to see if the dictionary has the aps key. This is the notification payload you would have sent if (options != null && options.ContainsKey(new NSString("aps"))) { #if DEBUG log(" ******* PROCESSING REMOTE NOTIFICATION Notification Payload received"); #endif NotificationData notificationData = new NotificationData(); string alert = string.Empty; string sound = string.Empty; int badge = -1; try { //Get the aps dictionary NSDictionary aps = options.ObjectForKey(new NSString("aps")) as NSDictionary; //Extract the alert text //NOTE: Just for the simple alert specified by " aps:{alert:"alert msg here"} " // For complex alert with Localization keys, etc., the "alert" object from the aps dictionary // will be another NSDictionary... Basically the json gets dumped right into a NSDictionary, so keep that in mind if (aps.ContainsKey(new NSString("alert"))) { string alertType = "undefined"; if (aps[new NSString("alert")].GetType() == typeof(NSString)) { alert = (aps [new NSString("alert")] as NSString).ToString(); alertType = "NSString"; } else if (aps [new NSString("alert")].GetType() == typeof(NSDictionary)) { NSDictionary alertNSDictionary = aps.ObjectForKey(new NSString("alert")) as NSDictionary; alertType = "NSDictionary"; // We only get "body" key from that dictionary if (alertNSDictionary.ContainsKey(new NSString("body")) && (alertNSDictionary[new NSString("body")].GetType() == typeof(NSString))) { alert = (alertNSDictionary [new NSString("body")] as NSString).ToString(); } } #if DEBUG log("******* PROCESSING NOTIFICATION Notification Payload contains an alert message. Type [" + alertType + "]"); #endif } //Extract the sound string if (aps.ContainsKey(new NSString("sound")) && (aps [new NSString("sound")].GetType() == typeof(NSString))) { sound = (aps [new NSString("sound")] as NSString).ToString(); #if DEBUG log("******* PROCESSING NOTIFICATION Notification Payload contains sound"); #endif } //Extract the badge if (aps.ContainsKey(new NSString("badge")) && (aps [new NSString("badge")].GetType() == typeof(NSObject))) { string badgeStr = (aps [new NSString("badge")] as NSObject).ToString(); int.TryParse(badgeStr, out badge); #if DEBUG log("******* PROCESSING NOTIFICATION Notification Payload contains a badge number: " + badge); #endif } //If this came from the ReceivedRemoteNotification while the app was running, // we of course need to manually process things like the sound, badge, and alert. if (!fromFinishedLaunching && applicationState == UIApplicationState.Active) { #if DEBUG log("******* PROCESSING NOTIFICATION app was running, so manually showing notification"); #endif UIRemoteNotificationType enabledRemoteNotificationTypes = UIApplication.SharedApplication.EnabledRemoteNotificationTypes; bool alertEnabled = ((enabledRemoteNotificationTypes & UIRemoteNotificationType.Alert) == UIRemoteNotificationType.Alert); bool soundEnabled = ((enabledRemoteNotificationTypes & UIRemoteNotificationType.Sound) == UIRemoteNotificationType.Sound); bool badgeEnabled = ((enabledRemoteNotificationTypes & UIRemoteNotificationType.Badge) == UIRemoteNotificationType.Badge); #if DEBUG log("******* PROCESSING NOTIFICATION types enabled: alert[" + alertEnabled + "], sound[" + soundEnabled + "], badge[" + badgeEnabled + "]"); #endif //Manually set the badge in case this came from a remote notification sent while the app was open if (badgeEnabled) { this.UpdateApplicationIconBadgeNumber(badge); } //Manually play the sound if (soundEnabled) { this.PlayNotificationSound(sound); } //Manually show an alert if (alertEnabled) { this.ShowNotificationAlert("Notification", alert); } } Dictionary <String, Object> customDic = IPhoneUtils.GetInstance().ConvertToDictionary(new NSMutableDictionary(options)); customDic.Remove("aps"); // it is not needed to pass the "aps" (notification iOS data) inside the "custom data json string" notificationData.CustomDataJsonString = IPhoneUtils.GetInstance().JSONSerialize(customDic); } catch (System.Exception ex) { #if DEBUG log(" ******* Unhanlded exception processing notification payload received. Exception message: " + ex.Message); #endif } finally { notificationData.AlertMessage = alert; notificationData.Badge = badge; notificationData.Sound = sound; IPhoneUtils.GetInstance().FireUnityJavascriptEvent("Unity.OnRemoteNotificationReceived", notificationData); } } else { #if DEBUG log(" ******* NO Notification Payload received"); #endif } }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { Log("Finished Launching"); Log("Starting GCM"); // Configure our core Google NSError err; Google.Core.Context.SharedInstance.Configure(out err); if (err != null) { Console.WriteLine("Failed to configure Google: {0}", err.LocalizedDescription); } Configuration = Google.Core.Context.SharedInstance.Configuration; // Configure and Start GCM var gcmConfig = Google.GoogleCloudMessaging.Config.DefaultConfig; gcmConfig.ReceiverDelegate = this; Service.SharedInstance.Start(gcmConfig); Log("Started GCM"); Log("Registering for Remote Notifications"); //// Register for remote notifications //var notTypes = UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge; //var settings = UIUserNotificationSettings.GetSettingsForTypes(notTypes, null); //UIApplication.SharedApplication.RegisterUserNotificationSettings(settings); //UIApplication.SharedApplication.RegisterForRemoteNotifications(); // registers for push var settings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(settings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); //// check for a notification if (launchOptions != null) { // check for a local notification if (launchOptions.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey)) { UILocalNotification localnotification = launchOptions[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification; if (localnotification != null) { //new UIAlertView(localnotification.AlertAction, localnotification.AlertBody, null, "ok", null).Show(); new UIAlertView("lauchOptions localnotification.AlertAction", "lauchOptions localnotification.AlertBody", null, "ok", null).Show(); // reset our badge UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0; } } // check for a remote notification if (launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey)) { NSDictionary remoteNotification = launchOptions[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary; if (remoteNotification != null) //if (launchOptions != null) { alertNotification(application, remoteNotification); //new UIAlertView("basdasdqrwqr", "adasdasd", null, "OK", null).Show(); //new UIAlertView("basdasdqrwqr", "adasdasd", null, "OK", null).Show();//remoteNotification["Body"].ToString() //new UIAlertView(remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show(); } } } if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null ); application.RegisterUserNotificationSettings(notificationSettings); application.RegisterForRemoteNotifications(); } else { //==== register for remote notifications and get the device token // set what kind of notification types we want UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge; // register for remote notifications UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } //end notifi return(true); }
//XFormsApplicationDelegate public override bool FinishedLaunching(UIApplication app, NSDictionary options) { this.SetIoc(); CachedImageRenderer.Init(); var ignore = new GrayscaleTransformation(); Rg.Plugins.Popup.IOS.Popup.Init(); //JPUSHService.SetDebugMode(); Xamarin.Behaviors.Infrastructure.Init(); RegistUpdateNavigationBar(); global::Xamarin.Forms.Forms.Init(); CopyLocalDB(); LoadApplication(new App()); Xamarin.Forms.Forms.ViewInitialized += (sender, e) => { if (!string.IsNullOrWhiteSpace(e.View.StyleId)) { e.NativeView.AccessibilityIdentifier = e.View.StyleId; } }; /***** * //jpush init start * //string advertisingId = ASIdentifierManager.SharedManager.AdvertisingIdentifier.ToString(); * if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) * { * //JPUSHRegisterEntity pushEntity = new JPUSHRegisterEntity(); * //pushEntity.Types = 4 | 1 | 2; * //JPushNotifyEvent notifyEvent = new JPushNotifyEvent(); * //JPUSHService.RegisterForRemoteNotificationConfig(pushEntity, notifyEvent); * } * else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) * { * JPUSHService.RegisterForRemoteNotificationTypes(4 | 1 | 2, new NSSet()); * } * else * { * JPUSHService.RegisterForRemoteNotificationTypes(4 | 1 | 2, new NSSet()); * } * * try * { * if (options == null) * { * options = new NSDictionary("_j_msgid", "-1", "aps", * new NSDictionary("alert", "12345", "badge", "0", "sound", "default")); * //options.SetValueForKey(new NSString("-1"), new NSString("_j_msgid")); * //NSDictionary subDic = new NSDictionary(); * //subDic.SetValueForKey(new NSString("alert"), new NSString("123456")); * //subDic.SetValueForKey(new NSString("badge"), new NSString("1")); * //subDic.SetValueForKey(new NSString("sound"), new NSString("default")); * //options.SetValueForKey(subDic, new NSString("aps")); * * JPUSHService.SetupWithOption(options, "35d7e27236095f67b93966b3", "", false, ""); * //JPUSHService.SetupWithOption(options, "5af3416249f70699720994dd", "", true, ""); * } * else * { * JPUSHService.SetupWithOption(options, "35d7e27236095f67b93966b3", "", false, ""); * //JPUSHService.SetupWithOption(options, "5af3416249f70699720994dd", "", true, ""); * } * } * catch (Exception) * { * * } ******/ if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { // Request notification permissions from the user UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert | UNAuthorizationOptions.Sound | UNAuthorizationOptions.Badge, (approved, err) => { // Handle approval if (approved) { UIApplication.SharedApplication.BeginInvokeOnMainThread(() => { UIApplication.SharedApplication.RegisterForRemoteNotifications(); UNUserNotificationCenter.Current.Delegate = new NotificationDelegate(); }); } }); } else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0; //jpush init end //app.ApplicationIconBadgeNumber = 0; //JPUSHService.ResetBadge(); ConfigureApplicationTheming(); App.ScreenHeight = int.Parse(UIScreen.MainScreen.Bounds.Height.ToString()); App.ScreenWidth = int.Parse(UIScreen.MainScreen.Bounds.Width.ToString()); return(base.FinishedLaunching(app, options)); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Xamarin.Forms.Forms.SetFlags(new string[] { "CarouselView_Experimental", "SwipeView_Experimental", "IndicatorView_Experimental", "MediaElement_Experimental" }); UINavigationBar.Appearance.TintColor = UIColor.Red; UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes() { TextColor = UIColor.Red }); //Actualizar el token de las notificaciones MessagingCenter.Subscribe <JobMe.ViewModels.MainEmployeeViewModel>(this, "DeleteToken", sender => { if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound, (granted, error) => { if (granted) { InvokeOnMainThread(UIApplication.SharedApplication.RegisterForRemoteNotifications); } }); } else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } }); MessagingCenter.Subscribe <JobMe.ViewModels.LoginViewModel>(this, "DeleteToken", sender => { if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { InvokeOnMainThread(UIApplication.SharedApplication.RegisterForRemoteNotifications); } else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } }); if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound, (granted, error) => { if (granted) { InvokeOnMainThread(UIApplication.SharedApplication.RegisterForRemoteNotifications); } }); } else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } global::Xamarin.Forms.Forms.Init(); SfPopupLayoutRenderer.Init(); SfPullToRefreshRenderer.Init(); SfCardLayoutRenderer.Init(); CarouselViewRenderer.Init(); SfTabViewRenderer.Init(); SfRotatorRenderer.Init(); SfBadgeViewRenderer.Init(); Syncfusion.XForms.iOS.Chat.SfChatRenderer.Init(); SfBorderRenderer.Init(); new SfComboBoxRenderer(); SfTextInputLayoutRenderer.Init(); SfMaskedEditRenderer.Init(); SfPdfDocumentViewRenderer.Init(); SfRangeSliderRenderer.Init(); SfPickerRenderer.Init(); SfListViewRenderer.Init(); SfEffectsViewRenderer.Init(); SfAvatarViewRenderer.Init(); SfMaskedEditRenderer.Init(); Syncfusion.XForms.iOS.PopupLayout.SfPopupLayoutRenderer.Init(); //SfRotatorRenderer.Init(); Syncfusion.XForms.iOS.Buttons.SfSegmentedControlRenderer.Init(); FFImageLoading.Forms.Platform.CachedImageRenderer.Init(); FormsVideoPlayer.Init(); CardsViewRenderer.Preserve(); App.ScreenWidth = UIScreen.MainScreen.Bounds.Width; App.ScreenHeight = UIScreen.MainScreen.Bounds.Height; LoadApplication(new App(false)); // LoadApplication(new App(false)); // Watch for notifications while the app is active UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate(); return(base.FinishedLaunching(app, options)); }
//resturar paquetes, actualizar limpiar compilar revisar que el infop.list este en 8 // 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(); ZXing.Net.Mobile.Forms.iOS.Platform.Init(); //paypal produccion AQrrFs8D-iSCYiAEEmO9ni3CcQ7GjgjPqSBBVhxNTmRKOnLR_Ol_qRcy2Pr4yxhwcQ2BK1BoZbzl0Hka //paypal sandbox AVART2W6j2cnNhmWej6EcQjx_ytsVpl1hmnArzHtVWSsZFRVAWOlZq6y3EjPFM0FHUhG_yrvkftXAAtN var config = new PayPalConfiguration(PayPalEnvironment.Production, "AQrrFs8D-iSCYiAEEmO9ni3CcQ7GjgjPqSBBVhxNTmRKOnLR_Ol_qRcy2Pr4yxhwcQ2BK1BoZbzl0Hka") //var config = new PayPalConfiguration(PayPalEnvironment.Sandbox, "AVART2W6j2cnNhmWej6EcQjx_ytsVpl1hmnArzHtVWSsZFRVAWOlZq6y3EjPFM0FHUhG_yrvkftXAAtN") { //If you want to accept credit cards AcceptCreditCards = false, //Your business name MerchantName = "Tienda", //Your privacy policy Url MerchantPrivacyPolicyUri = "http://tratoespecial.com/politicas-de-privacidad/", //Your user agreement Url MerchantUserAgreementUri = "http://tratoespecial.com/terminos-y-condiciones/", // OPTIONAL - ShippingAddressOption (Both, None, PayPal, Provided) ShippingAddressOption = ShippingAddressOption.Both, // OPTIONAL - Language: Default languege for PayPal Plug-In Language = "es", // OPTIONAL - PhoneCountryCode: Default phone country code for PayPal Plug-In PhoneCountryCode = "52", }; CrossPayPalManager.Init(config); LoadApplication(new App()); if (options != null) { //check for remote notification if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey)) { NSDictionary _remoteNotif = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary; if (_remoteNotif != null) { // new UIAlertView(_remoteNotif.a) } } } // pedir permiso para enviar notificaciones if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { // iOS 8 or later var notifSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null); // For iOS 8 display notification (sent via APNS) app.RegisterUserNotificationSettings(notifSettings); app.RegisterForRemoteNotifications(); /* UNUserNotificationCenter.Current.Delegate = this; * System.Diagnostics.Debug.WriteLine($"antes 11: {app.IsRegisteredForRemoteNotifications.ToString()}"); * UIApplication.SharedApplication.RegisterForRemoteNotifications(); * System.Diagnostics.Debug.WriteLine($"despues 11: {app.IsRegisteredForRemoteNotifications.ToString()}");*/ } else { //register for remote notifications and get the device token //set what kind of notifiaction type we want UIRemoteNotificationType _notifTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge; //register for remtote notif UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(_notifTypes); /*var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound; * var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null); * UIApplication.SharedApplication.RegisterUserNotificationSettings(settings); * System.Diagnostics.Debug.WriteLine($"antes 9: {app.IsRegisteredForRemoteNotifications.ToString()}"); * UIApplication.SharedApplication.RegisterForRemoteNotifications(); * System.Diagnostics.Debug.WriteLine($"despues 9: {app.IsRegisteredForRemoteNotifications.ToString()}");*/ } Firebase.Core.App.Configure(); Firebase.InstanceID.InstanceId.Notifications.ObserveTokenRefresh((sender, e) => { var newtoken = Firebase.InstanceID.InstanceId.SharedInstance.Token; System.Diagnostics.Debug.WriteLine($"FCM Token observe: {newtoken}"); App.Fn_SetToken(newtoken); }); //Firebase.InstanceID.InstanceId.TokenRefreshNotification; //debugAlert(UIApplication.SharedApplication.IsRegisteredForRemoteNotifications.ToString(),V_Token); // Console.WriteLine(" token device " + V_Token); //https://github.com/codercampos/FirebaseXF-XamarinLatino/blob/master/src/FirebaseXL/FirebaseXL.iOS/AppDelegate.cs // blog.xamarians.com/blog/2017/9/18/firebase-cloud-messaging return(base.FinishedLaunching(app, options)); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); // Code for starting up the Xamarin Test Cloud Agent #if ENABLE_TEST_CLOUD Xamarin.Calabash.Start(); #endif LoadApplication(new App()); // Handling Push notification when app is closed if App was opened by Push Notification... if (options != null && options.Keys != null && options.Keys.Count() != 0 && options.ContainsKey(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey"))) { NSDictionary UIApplicationLaunchOptionsRemoteNotificationKey = options.ObjectForKey(new NSString("UIApplicationLaunchOptionsRemoteNotificationKey")) as NSDictionary; ProcessNotification(UIApplicationLaunchOptionsRemoteNotificationKey, true); } //added on 1/7/17 by aditmer to see if the device token from APNS has changed (like after an app update) if (ApplicationSettings.InstallationID != "") { //Push notifications registration if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } } //added on 1/4/17 by aditmer to add 4 (1/6/17) customizable snooze options int snoozeTime1 = 1; int snoozeTime2 = 2; int snoozeTime3 = 3; int snoozeTime4 = 4; if (ApplicationSettings.AlarmUrgentLowMins1 != 0) { snoozeTime1 = ApplicationSettings.AlarmUrgentLowMins1; } if (ApplicationSettings.AlarmUrgentLowMins2 != 0) { snoozeTime2 = ApplicationSettings.AlarmUrgentLowMins2; } if (ApplicationSettings.AlarmUrgentMins1 != 0) { snoozeTime3 = ApplicationSettings.AlarmUrgentMins1; } if (ApplicationSettings.AlarmUrgentMins2 != 0) { snoozeTime4 = ApplicationSettings.AlarmUrgentMins2; } //added on 12/03/16 by aditmer to add custom actions to the notifications (I think this code goes here) // Create action var actionID = "snooze1"; var title = $"Snooze {snoozeTime1} minutes"; var action = UNNotificationAction.FromIdentifier(actionID, title, UNNotificationActionOptions.None); var actionID2 = "snooze2"; var title2 = $"Snooze {snoozeTime2} minutes"; var action2 = UNNotificationAction.FromIdentifier(actionID2, title2, UNNotificationActionOptions.None); var actionID3 = "snooze3"; var title3 = $"Snooze {snoozeTime3} minutes"; var action3 = UNNotificationAction.FromIdentifier(actionID3, title3, UNNotificationActionOptions.None); var actionID4 = "snooze4"; var title4 = $"Snooze {snoozeTime4} minutes"; var action4 = UNNotificationAction.FromIdentifier(actionID4, title4, UNNotificationActionOptions.None); // Create category var categoryID = "event"; var actions = new List <UNNotificationAction> { action, action2, action3, action4 }; var intentIDs = new string[] { }; var categoryOptions = new UNNotificationCategoryOptions[] { }; //added on 1/19/17 by aditmer to remove duplicate snooze options (they can be custom set by each user in their Nightscout settings) actions = actions.DistinctBy((arg) => arg.Title).ToList(); var category = UNNotificationCategory.FromIdentifier(categoryID, actions.ToArray(), intentIDs, UNNotificationCategoryOptions.AllowInCarPlay); // Register category var categories = new UNNotificationCategory[] { category }; UNUserNotificationCenter.Current.SetNotificationCategories(new NSSet <UNNotificationCategory>(categories)); return(base.FinishedLaunching(app, options)); }
// // 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(); VideoViewRenderer.Init(); AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; TaskScheduler.UnobservedTaskException += TaskSchedulerOnUnobservedTaskException; ImageCircleRenderer.Init(); FloatingActionButtonViewRenderer.Init(); _secureStorage = DependencyService.Get <ISecureStorage>(); try { // check for a notification if (options != null) { // check for a local notification if (options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey)) { if (options[UIApplication.LaunchOptionsLocalNotificationKey] is UILocalNotification localNotification) { var action = localNotification.AlertAction; var body = localNotification.AlertBody; var alert = new UIAlertView() { Title = action, Message = body }; alert.AddButton("OK"); alert.Show(); // reset our badge UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0; } } // check for a remote notification if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey)) { if (options[UIApplication.LaunchOptionsRemoteNotificationKey] is NSDictionary remoteNotification ) { //new UIAlertView(remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show(); } } } } catch (System.Exception ex) { new ExceptionHandler(TAG, ex); } try { // REGISTER : REMOTE PUSH NOTIFICATION //#if DEBUG // // NO PUSH NOTIFICATION REGISTRATION FOR DEBUGGING MODE //#else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); // register for remote notifications UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { //==== register for remote notifications and get the device token // set what kind of notification types we want UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; // register for remote notifications UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } //#endif // Watch for notifications while the app is active UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate(); // Get current notification settings UNUserNotificationCenter.Current.GetNotificationSettings((settings) => { var alertsAllowed = (settings.AlertSetting == UNNotificationSetting.Enabled); }); } catch (System.Exception ex) { new ExceptionHandler(TAG, ex); } LoadApplication(new App()); return(base.FinishedLaunching(app, options)); }
public virtual void RegisterForRemoteNotificationTypes(UIRemoteNotificationType types) { }
async public override void ViewDidLoad() { base.ViewDidLoad(); try { if (string.IsNullOrEmpty(sUserAccountNumber)) { sUserAccountNumber = "0000"; } ImagePersonalQRCode.Image = IosHelper.GetQrCode(sUserAccountNumber, 240, 240, 0); lblCustomerId.Text = sUserAccountNumber; lblQRCodeBackground.Layer.CornerRadius = 10f; lblQRCodeBackground.Layer.MasksToBounds = true; qrCodePlaceHolderBorder.Layer.CornerRadius = 10f; qrCodePlaceHolderBorder.Layer.MasksToBounds = true; qrCodePlaceHolderBorder.Layer.BorderColor = UIColor.White.CGColor; qrCodePlaceHolderBorder.Layer.BorderWidth = 1f; if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } //string sAccessToken = Helpers.Settings.AccessToken; //string sUserEmail = Helpers.Settings.UserEmail; //if (!string.IsNullOrEmpty(sAccessToken) && !string.IsNullOrEmpty(sUserEmail)) //{ // Joyces.Platform.AppContext.Instance.Platform.CustomerId = sUserEmail; // var getCustomer = await RestAPI.GetCustomer(sUserEmail, sAccessToken); // if (getCustomer != null && getCustomer is Customer) // { // Joyces.Platform.AppContext.Instance.Platform.CustomerList = (Customer)getCustomer; // var resp = await RestAPI.GetOffer(sUserEmail, sAccessToken); // if (resp != null && resp is List<Offer>) // Joyces.Platform.AppContext.Instance.Platform.OfferList = (List<Offer>)resp; // else // Joyces.Platform.AppContext.Instance.Platform.OfferList = null; // resp = await RestAPI.GetNews(sUserEmail, sAccessToken); // if (resp != null && resp is List<Joyces.News>) // Joyces.Platform.AppContext.Instance.Platform.NewsList = (List<Joyces.News>)resp; // else // Joyces.Platform.AppContext.Instance.Platform.NewsList = null; // Joyces.Platform.AppContext.Instance.Platform.MoreList = await RestAPI.GetMore(sAccessToken); // } // else // { // Helpers.Settings.AccessToken = string.Empty; // Helpers.Settings.UserEmail = string.Empty; // var mainController = Storyboard.InstantiateViewController("loginNavigationController"); // UIApplication.SharedApplication.KeyWindow.RootViewController = mainController; // } //} //else //{ // //Något är JÄÄÄVLIGT FEL, hit ska den absolut aldrig kunna komma!!! // Helpers.Settings.AccessToken = string.Empty; // Helpers.Settings.UserEmail = string.Empty; // var mainController = Storyboard.InstantiateViewController("loginNavigationController"); // UIApplication.SharedApplication.KeyWindow.RootViewController = mainController; // return; //} if (!string.IsNullOrEmpty(Joyces.Helpers.Settings.AccessToken)) { sendDeviceToken(Joyces.Helpers.Settings.AccessToken); } } catch (Exception ex) { } }
public void RegisterForRemoteNotificationTypes(UIRemoteNotificationType types) { ObjC.MessageSend(Handle, Selector.GetHandle("registerForRemoteNotificationTypes:"), (int)types); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { try { //downloading all wine images BlobWrapper.DownloadAllImages(); // Override point for customization after application launch. // If not required for your application you can safely delete this method UITabBarController RootTab = (UITabBarController)Window.RootViewController; //CurrentUser.Clear(); CurrentUser.Store("48732", "user Simulator"); //for direct log in //CurrentUser.PutCa rdNumber("7207589007"); //Console.WriteLine(DateTime.Now + " App opened"); UIImage profile = UIImage.FromFile("profile.png"); profile = ResizeImage(profile, 25, 25); _window = Window; UIImage info = UIImage.FromFile("Info.png"); info = ResizeImage(info, 25, 25); //Checking the user already logged in or not if (CurrentUser.RetreiveUserId() != 0) { ManageTabBar(RootTab); LoggingClass.LogInfo("App opened " + CurrentUser.RetreiveUserId(), screen); nav = new UINavigationController(RootTab); //Window.RootViewController = RootTab; AddNavigationButtons(nav); UIBarButtonItem.Appearance.TintColor = UIColor.FromRGB(128, 0, 128); Window.RootViewController = nav; } //Checking Guest logged in or not else if (CurrentUser.GetGuestId() != "0" && CurrentUser.GetGuestId() != null) { CurrentUser.Store("0", "Guest"); ManageTabBar(RootTab); //Console.WriteLine(DateTime.Now + " App opened"); nav = new UINavigationController(RootTab); //Window.RootViewController = RootTab; AddNavigationButtons(nav); UIBarButtonItem.Appearance.TintColor = UIColor.FromRGB(128, 0, 128); Window.RootViewController = nav; } else { ManageTabBar(RootTab); var login = new LoginViewController(); login.RootTabs = Window.RootViewController; login._window = Window; nav = new UINavigationController(login); //nav.NavigationBar.BackgroundColor = UIColor.FromRGB(97, 100, 142); UIBarButtonItem.Appearance.TintColor = UIColor.FromRGB(128, 0, 128); Window.RootViewController = nav; } } catch (Exception exe) { LoggingClass.LogError(exe.Message, screen, exe.StackTrace); } //Notification Settings if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var pushSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } else { UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } return(true); }
public void RegisterForRemoteNotificationTypes(UIRemoteNotificationType types) { ObjC.MessageSend(Handle, "registerForRemoteNotificationTypes:", (int)types); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { // Override point for customization after application launch. // If not required for your application you can safely delete this method Window = new UIWindow(UIScreen.MainScreen.Bounds); Window.BackgroundColor = UIColor.GroupTableViewBackgroundColor; #region 极光推送注册 MsgBoxHelper.Initialize(this); if (float.Parse(UIDevice.CurrentDevice.SystemVersion.Split('.')[0]) >= 10.0) { UNUserNotificationCenter center = UNUserNotificationCenter.Current; center.RequestAuthorization((UNAuthorizationOptions.CarPlay | UNAuthorizationOptions.Alert | UNAuthorizationOptions.Sound | UNAuthorizationOptions.Badge), (bool arg1, NSError arg2) => { if (arg1) { Console.WriteLine("ios 10 request notification success"); } else { Console.WriteLine("IOS 10 request notification failed"); } }); } else if (float.Parse(UIDevice.CurrentDevice.SystemVersion.Split('.')[0]) >= 8.0) { UIUserNotificationSettings notiSettings = UIUserNotificationSettings.GetSettingsForTypes(UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert, null); UIApplication.SharedApplication.RegisterUserNotificationSettings(notiSettings); } else { UIRemoteNotificationType myTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Sound | UIRemoteNotificationType.Badge; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(myTypes); } /* * JPUSHService.SetupWithOption(launchOptions, "466439cd8279089311ead639", "Publish channel", false); * 将上面代码中的应用程序码换成你在极光服务器上注册的应用码,通过极光服务器发送推送消息,在真机上测试即可收到。 */ JPUSHService.SetupWithOption(launchOptions, "466439cd8279089311ead639", "Publish channel", false); JPUSHService.SetDebugMode(); UIApplication.SharedApplication.RegisterForRemoteNotifications(); //JPUSHService.RegistrationIDCompletionHandler((int arg1, NSString arg2) => //{ // if (arg1 == 0) // Console.WriteLine(arg2); //}); if (launchOptions != null) { NSDictionary remoteNotification = (NSDictionary)(launchOptions.ObjectForKey(UIApplication.LaunchOptionsRemoteNotificationKey)); if (remoteNotification != null) { Console.WriteLine(remoteNotification); this.goToMessageViewControllerWith(remoteNotification); } } #endregion Window.RootViewController = new UINavigationController(new ViewController()); // make the window visible Window.MakeKeyAndVisible(); return(true); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { // Override point for customization after application launch. // If not required for your application you can safely delete this method Window = new UIWindow(UIScreen.MainScreen.Bounds); // set our root view controller with the sidebar menu as the apps root view controller Window.RootViewController = new RootViewController(); Window.MakeKeyAndVisible(); #region Check for a Notification // check for a notification if (launchOptions != null) { // check for a local notification if (launchOptions.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey)) { UILocalNotification localNotification = launchOptions[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification; if (localNotification != null) { new UIAlertView(localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show(); // reset our badge UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0; } } // check for a remote notification if (launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey)) { NSDictionary remoteNotification = launchOptions[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary; if (remoteNotification != null) { //new UIAlertView(remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show(); } } } if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null ); application.RegisterUserNotificationSettings(notificationSettings); application.RegisterForRemoteNotifications(); } else { //==== register for remote notifications and get the device token // set what kind of notification types we want UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge; // register for remote notifications UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); } var googleServiceDictionary = NSDictionary.FromFile("GoogleService-Info.plist"); SignIn.SharedInstance.ClientID = googleServiceDictionary["CLIENT_ID"].ToString(); #endregion //Profile.EnableUpdatesOnAccessTokenChange(true); //Settings.AppID = appId; //Settings.DisplayName = appName; //return ApplicationDelegate.SharedInstance.FinishedLaunching(application, launchOptions); return(true); }
public override void ExtractTokenAndRegister() { const UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound; UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes); }