// In the status dictionary: // "FoundBarcodes" key is a NSSet of all discovered barcodes this scan session // "NewFoundBarcodes" is a NSSet of barcodes discovered in the most recent pass. // When a barcode is found, it is added to both sets. The NewFoundBarcodes // set is cleaned out each pass. // "Guidance" can be used to help guide the user through the process of discovering // a long barcode in sections. Currently only works for Code 39. // "Valid" is TRUE once there are valid barcode results. // "InRange" is TRUE if there's currently a barcode detected the viewfinder. The barcode // may not have been decoded yet. public override void StatusUpdated(BarcodePickerController picker, NSDictionary status) { NSNumber isValid = (NSNumber) status.ObjectForKey (new NSString ("Valid")); NSNumber inRange = (NSNumber) status.ObjectForKey (new NSString ("InRange")); SetArrows (inRange.BoolValue, true); if (isValid.BoolValue) { BeepOrVibrate (); ParentPicker.DoneScanning (); } NSNumber guidanceLevel = (NSNumber) status.ObjectForKey (new NSString ("Guidance")); if (guidanceLevel != null) { if (guidanceLevel.IntValue == 1) { textCue.Text = "Try moving the camera close to each part of the barcode"; } else if (guidanceLevel.IntValue == 2) { textCue.Text = (NSString) status.ObjectForKey (new NSString ("PartialBarcode")); } else { textCue.Text = ""; } } }
public static Photo PhotoWithDictionary (NSDictionary dictionary) { return new Photo { ImageName = (NSString)dictionary.ObjectForKey (new NSString ("imageName")), Comment = (NSString)dictionary.ObjectForKey (new NSString ("comment")), Rating = ((NSNumber)dictionary.ObjectForKey (new NSString ("rating"))).Int32Value, }; }
public override void HandleResult(FBRequest request, NSDictionary dict) { if (dict.ObjectForKey(new NSString("owner")) != null) { } else { NSObject id = dict.ObjectForKey(new NSString("id")); _controller.GetPIDforPhotoFBID(id.ToString(), AutoTag); } }
public override void HandleResult(FBRequest request, NSDictionary dict) { if (dict.ObjectForKey(new NSString("owner")) != null) { } else { NSObject id = dict.ObjectForKey(new NSString("id")); _facebookController.LoggedIn(id.ToString()); } }
public virtual void Awake(NSArray rootObjects, IBObjectContainer objects, NSDictionary context) { NSEnumerator en; id obj; NSMutableArray topLevelObjects = (NSMutableArray)context.ObjectForKey((id)NS.NibTopLevelObjects); id owner = context.ObjectForKey(NS.NibOwner); id first = null; id app = null; // Get the file's owner and NSApplication object references... if (((NSCustomObject)rootObjects.ObjectAtIndex(1)).ClassName.IsEqualToString(@"FirstResponder")) first = ((NSCustomObject)rootObjects.ObjectAtIndex(1)).RealObject; else NS.Log(@"%s:first responder missing\n", "Awake"); if (((NSCustomObject)rootObjects.ObjectAtIndex(2)).ClassName.IsEqualToString(@"NSApplication")) app = ((NSCustomObject)rootObjects.ObjectAtIndex(2)).RealObject; else NS.Log(@"%s:NSApplication missing\n", "Awake"); // Use the owner as first root object ((NSCustomObject)rootObjects.ObjectAtIndex(0)).SetRealObject(owner); en = rootObjects.ObjectEnumerator(); while ((obj = en.NextObject()) != null) { if (obj.RespondsToSelector(new SEL("NibInstantiate"))) { obj = (id)Objc.MsgSend(obj, "NibInstantiate", null); } // IGNORE file's owner, first responder and NSApplication instances... if ((obj != null) && (obj != owner) && (obj != first) && (obj != app)) { topLevelObjects.AddObject(obj); // All top level objects must be released by the caller to avoid // leaking, unless they are going to be released by other nib // objects on behalf of the owner. //RETAIN(obj); } //FIXME //if ((obj.IsKindOfClass(NSMenu.Class)) && // (((NSMenu)obj _isMainMenu])) // { // // add the menu... // NSApp._setMainMenu(obj); // } } // Load connections and awaken objects Objc.MsgSend(objects, "NibInstantiate", null); }
public static Conversation ConversationWithDictionary (NSDictionary dictionary) { var photoValues = (NSArray)dictionary.ObjectForKey (new NSString ("photos")); var photos = new NSMutableArray (photoValues.Count); for (nint i = 0; i < (nint)photoValues.Count; i++) { var photo = Photo.PhotoWithDictionary (photoValues.GetItem <NSDictionary> (i)); photos.Add (photo); } return new Conversation { Name = (NSString)dictionary.ObjectForKey (new NSString ("name")), Photos = photos }; }
/// <summary> /// Will be called if app received a remote notification. /// According to Apple's docs this is the preferred method to use instead of ReceivedRemoteNotification(). /// See: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/#//apple_ref/occ/intfm/UIApplicationDelegate/application:didReceiveRemoteNotification:fetchCompletionHandler: /// Use this method to process incoming remote notifications for your app. /// Unlike the application:didReceiveRemoteNotification: method, which is called only when your app is running in the foreground, /// the system calls this method when your app is running in the foreground or background. In addition, /// if you enabled the remote notifications background mode, the system launches your app (or wakes it from the suspended state) /// and puts it in the background state when a remote notification arrives. However, the system does not automatically launch your app if the user has force-quit it. /// In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again. /// </summary> public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action <UIBackgroundFetchResult> completionHandler) { // This will be called if the app is in the background/not running and if in the foreground. // However, it will not display a notification visually if the app is in the foreground. // Extract some data from the notifiation and display it using an alert view. NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary; var alert = string.Empty; if (aps.ContainsKey(new NSString("alert"))) { alert = (aps[new NSString("alert")] as NSString).ToString(); } // Show alert if (!string.IsNullOrEmpty(alert)) { ((App)App.Current).ShowNotification(alert); } // We must call the completion handler as soon as possible, max. after 30 seconds, otherwise the app gets terminated. // If we use notifications to download something, we would return "UIBackgroundFetchResult.NewData". completionHandler(UIBackgroundFetchResult.NoData); }
public static EddystoneFrameType FrameTypeForFrame(NSDictionary advertisementFrameList) { var frameData = advertisementFrameList.ObjectForKey(CBUUID.FromString("FEAA")) as NSData; if (frameData != null && frameData.Length >= 1) { var frameBytes = frameData.ToArray(); if (frameBytes[0] == EddystoneUIDFrameTypeID) { return(EddystoneFrameType.UIDFrameType); } else if (frameBytes[0] == EddystoneTLMFrameTypeID) { return(EddystoneFrameType.TelemetryFrameType); } else if (frameBytes[0] == EddystoneEIDFrameTypeID) { return(EddystoneFrameType.EIDFrameType); } else if (frameBytes[0] == EddystoneURLFrameTypeID) { return(EddystoneFrameType.URLFrameType); } else { return(EddystoneFrameType.UnknownFrameType); } } return(EddystoneFrameType.UnknownFrameType); }
void ProcessNotification(NSDictionary options, bool fromFinishedLaunching) { // Check to see if the dictionary has the aps key. This is the notification payload you would have sent if (null != options && options.ContainsKey(new NSString("aps"))) { //Get the aps dictionary NSDictionary aps = options.ObjectForKey(new NSString("aps")) as NSDictionary; string alert = string.Empty; //Extract the alert text //NOTE: If you're using the simple alert by just specifying " aps:{alert:"alert msg here"} " // this will work fine. But if you're using a complex alert with Localization keys, etc., your "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"))) { alert = (aps [new NSString("alert")] as NSString).ToString(); } //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) { //Manually show an alert if (!string.IsNullOrEmpty(alert)) { UIAlertView avAlert = new UIAlertView("Notification", alert, null, "OK", null); avAlert.Show(); } } } }
public void ObserveValueForKeyPath(NSString keyPath, NSObject obj, NSDictionary change, IntPtr context) { if (context != this.Handle) { // If the context does not match, this message // must be intended for our superclass base.ObserveValue(keyPath, obj, change, context); return; } NSUndoManager undo = this.UndoManager; NSObject oldValue = change.ObjectForKey(ChangeOldKey); // NSNull objects are used to represent nil in a dictinoary if (oldValue == NSNull.Null) { oldValue = null; } Console.WriteLine("oldValue = {0}", oldValue); NSArray args = NSArray.FromObjects(new object[] { keyPath, obj, oldValue }); undo.RegisterUndoWithTarget(this, new Selector("changeKeyPathofObjecttoValue:"), args); undo.SetActionname("Edit"); // Sort if necessary arrayController.RearrangeObjects(); // Keep the row selected. // Without this, the row is selected in gray (tableView loses focus) and the arrow keys don't work to navigate to other items // and the return key does not trigger editing of the item again. tableView.EditColumn(0, tableView.SelectedRow, null, false); }
private void receivedPushNotification(NSDictionary userInfo, UIApplication application) { if (application.ApplicationState == UIApplicationState.Active) { return; } var aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary; if (aps != null) { string message = aps.ObjectForKey(new NSString("alert")) as NSString; var parameters = aps.ObjectForKey(new NSString("parameters")) as NSDictionary; NSError error; var json = NSJsonSerialization.Serialize(parameters, NSJsonWritingOptions.PrettyPrinted, out error); Newtonsoft.Json.Linq.JObject jObject = Newtonsoft.Json.Linq.JObject.Parse(json.ToString(NSStringEncoding.UTF8)); Notification _notification = new Notification() { Message = message, Parameters = jObject }; crossApp.OnPushNotification(_notification); } }
private void handleAuthorizationError(NSError authorizationError) { NSDictionary unauthorizedAPIInfo = (NSDictionary)authorizationError.UserInfo.ObjectForKey(WTAuthorizationRequestManager.WTUnauthorizedAppleiOSSDKAPIsKey); NSMutableString detailedAuthorizationErrorLogMessage = (NSMutableString) new NSString("The following authorization states do not meet the requirements:").MutableCopy(); NSMutableString missingAuthorizations = (NSMutableString) new NSString("In order to use the Wikitude SDK, please grant access to the following:").MutableCopy(); foreach (NSString unauthorizedAPIKey in unauthorizedAPIInfo.Keys) { NSNumber unauthorizedAPIValue = (NSNumber)unauthorizedAPIInfo.ObjectForKey(unauthorizedAPIKey); detailedAuthorizationErrorLogMessage.Append(new NSString("\n")); detailedAuthorizationErrorLogMessage.Append(unauthorizedAPIKey); detailedAuthorizationErrorLogMessage.Append(new NSString(" = ")); detailedAuthorizationErrorLogMessage.Append(WTAuthorizationRequestManager.StringFromAuthorizationStatusForUnauthorizedAppleiOSSDKAPI(unauthorizedAPIValue.Int32Value, unauthorizedAPIKey)); missingAuthorizations.Append(new NSString("\n *")); missingAuthorizations.Append(WTAuthorizationRequestManager.HumanReadableDescriptionForUnauthorizedAppleiOSSDKAPI(unauthorizedAPIKey)); } Console.WriteLine(detailedAuthorizationErrorLogMessage); UIAlertController settingsAlertController = UIAlertController.Create("Required API authorizations missing", missingAuthorizations, UIAlertControllerStyle.Alert); settingsAlertController.AddAction(UIAlertAction.Create("Open Settings", UIAlertActionStyle.Default, (UIAlertAction obj) => { UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString)); })); settingsAlertController.AddAction(UIAlertAction.Create("NO", UIAlertActionStyle.Destructive, (UIAlertAction obj) => { })); this.PresentViewController(settingsAlertController, true, null); }
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action <UIBackgroundFetchResult> completionHandler) { NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary; // The aps is a dictionary with the template values in it // You can adjust this section to do whatever you need to with the push notification string alert = string.Empty; if (aps.ContainsKey(new NSString("alert"))) { alert = (aps[new NSString("alert")] as NSString).ToString(); } string badge = string.Empty; if (aps.ContainsKey(new NSString("badge"))) { badge = (aps[new NSString("badge")] as NSNumber).ToString(); } string payload = string.Empty; if (aps.ContainsKey(new NSString("payload"))) { payload = (aps[new NSString("payload")] as NSString).ToString(); } var payloadData = JsonConvert.DeserializeObject <NotificationPayload>(payload); DisplayAlert("Success", alert + " " + badge); }
void ProcessNotification( NSDictionary options, bool fromFinishedLaunching) { if (null != options && options.ContainsKey(new NSString("aps"))) { NSDictionary aps = options.ObjectForKey(new NSString("aps")) as NSDictionary; string alert = string.Empty; string type = string.Empty; string notification = string.Empty; if (aps.ContainsKey(new NSString("alert"))) { alert = (aps[new NSString("alert")] as NSString).ToString(); } //type = (aps[new NSString("Type")] as NSString).ToString(); if (!fromFinishedLaunching) { //notification = (aps[new NSString("Notification")] as NSString).ToString(); var avAlert = new UIAlertView( "Products App", alert, null, "Ok", null); avAlert.Show(); } } }
void ProcessNotification(NSDictionary userInfo) { if (userInfo == null) { return; } Console.WriteLine("Received Notification"); var apsKey = new NSString("aps"); if (userInfo.ContainsKey(apsKey)) { var alertKey = new NSString("alert"); var aps = (NSDictionary)userInfo.ObjectForKey(apsKey); if (aps.ContainsKey(alertKey)) { var alert = (NSString)aps.ObjectForKey(alertKey); try { var avAlert = new UIAlertView("Conference Update", alert, null, "OK", null); avAlert.Show(); } catch (Exception ex) { } Console.WriteLine("Notification: " + alert); } } }
public Models.MunkiPackageInfo ReadPlist(string fileName) { try { NSDictionary rootDict = (NSDictionary)PropertyListParser.Parse(fileName); var plist = new Models.MunkiPackageInfo(); plist.Name = rootDict.ObjectForKey("name").ToString(); plist.Version = rootDict.ObjectForKey("version").ToString(); return(plist); } catch (Exception ex) { Logger.Log(ex.Message); return(null); } }
/// <summary> /// Processes any received launch options. /// </summary> /// <param name="options">Options.</param> /// <param name="fromFinishedLaunching">True if this method comes from the 'FinishedLaunching' delegated method</param> /// <param name="applicationState">The application state that received the special launch options</param> public void processLaunchOptions(NSDictionary options, bool fromFinishedLaunching, UIApplicationState applicationState) { try { #if DEBUG log("******* Checking launch optioins (if available) fromFinishedLaunching=" + fromFinishedLaunching + ". application state: " + applicationState); #endif if (options != null) { // LOCAL NOTIFICATIONS UILocalNotification localNotif = (UILocalNotification)options.ObjectForKey(UIApplication.LaunchOptionsLocalNotificationKey); this.ProcessLocalNotification(applicationState, localNotif); } else { #if DEBUG log("******* NO launch options"); #endif } } catch (System.Exception ex) { #if DEBUG log("******* Unhandled exception when trying to process notification. fromFinishedLaunching[" + fromFinishedLaunching + "]. Exception message: " + ex.Message); #endif } }
public AppDelegate () { PrepareCache (); ExtractImages (); controller = new MonodocDocumentController (); // Some UI feature we use rely on Lion, so special case it try { var version = new NSDictionary ("/System/Library/CoreServices/SystemVersion.plist"); isOnLion = version.ObjectForKey (new NSString ("ProductVersion")).ToString ().StartsWith ("10.7"); } catch {} // Load documentation Root = RootTree.LoadTree (null); var macDocPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "macdoc"); if (!Directory.Exists (macDocPath)) Directory.CreateDirectory (macDocPath); IndexUpdateManager = new IndexUpdateManager (Root.HelpSources.Cast<HelpSource> ().Select (hs => Path.Combine (hs.BaseFilePath, hs.Name + ".zip")).Where (File.Exists), macDocPath); BookmarkManager = new BookmarkManager (macDocPath); AppleDocHandler = new AppleDocHandler ("/Library/Frameworks/Mono.framework/Versions/Current/etc/"); // Configure the documentation rendering. SettingsHandler.Settings.EnableEditing = false; SettingsHandler.Settings.preferred_font_size = 200; HelpSource.use_css = true; }
private void ProcessNotification(NSDictionary options, bool fromFinishedLaunching) { if (null == options || !options.ContainsKey(new NSString("aps"))) { return; } var aps = options.ObjectForKey(new NSString("aps")) as NSDictionary; var alert = string.Empty; if (aps != null && aps.ContainsKey(new NSString("alert"))) { alert = (aps[new NSString("alert")] as NSString)?.ToString(); } if (fromFinishedLaunching) { return; } if (string.IsNullOrEmpty(alert)) { return; } var avAlert = new UIAlertView("Ferreyros", alert, null, "OK", null); avAlert.Show(); }
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary options, Action <UIBackgroundFetchResult> completionHandler) { if (null != options && options.ContainsKey(new NSString("aps"))) { string alert = string.Empty; string sound = string.Empty; int badge = -1; NSDictionary aps = options.ObjectForKey(new NSString("aps")) as NSDictionary; NSDictionary json = (aps["moredata"] as NSDictionary); NotificatonModel.RemoteNoti objNotification = new NotificatonModel.RemoteNoti(); objNotification.message_id = json["message_id"].ToString(); objNotification.msg = json["msg"].ToString(); objNotification.notification_type = json["notification_type"].ToString(); objNotification.registration_ids = json["registration_ids"].ToString(); objNotification.to_id = json["to_id"].ToString(); objNotification.user_id = json["user_id"].ToString(); if (objNotification.notification_type.Equals("message")) { MessagingCenter.Send <object, NotificatonModel.RemoteNoti>(this, "NotificationRecieved", objNotification); } } }
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo) { var aps = userInfo.ObjectForKey (new NSString ("aps")) as NSDictionary; var alert = aps.ObjectForKey (new NSString ("alert")).ToString (); var av = new UIAlertView ("推æ’通知", alert, null, "確定", null); av.Show (); }
void ProcessNotification(NSDictionary options, bool fromFinishedLaunching) { // Check to see if the dictionary has the aps key. This is the notification payload you would have sent if (null != options && options.ContainsKey(new NSString("aps"))) { //Get the aps dictionary NSDictionary aps = options.ObjectForKey(new NSString("aps")) as NSDictionary; string message = string.Empty; //Extract the alert text // NOTE: If you're using the simple alert by just specifying // " aps:{alert:"alert msg here"} ", this will work fine. // But if you're using a complex alert with Localization keys, etc., // your "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"))) { message = (aps[new NSString("alert")] as NSString).ToString(); } //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) { //Manually show an alert if (!string.IsNullOrEmpty(message)) { MessagingCenter.Send <object, string>(this, App.NotificationReceivedKey, message); } } } }
private void ProcessNotification(NSDictionary options, bool fromFinishedLaunching) { if (null != options && options.ContainsKey(new NSString("aps"))) { NSDictionary aps = options.ObjectForKey(new NSString("aps")) as NSDictionary; string alert = string.Empty; if (aps.ContainsKey(new NSString("alert"))) { alert = (aps[new NSString("alert")] as NSString).ToString(); } //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) { //Manually show an alert if (!string.IsNullOrEmpty(alert)) { UserDialogs.Instance.Alert(alert, "Notification", "OK"); } } } }
void ProcessNotification(NSDictionary options, bool fromFinishedLaunching) { // Check to see if the dictionary has the aps key. This is the notification payload you would have sent if (null != options && options.ContainsKey(new NSString("aps"))) { //Get the aps dictionary NSDictionary aps = options.ObjectForKey(new NSString("aps")) as NSDictionary; string alert = string.Empty; //Extract the alert text // NOTE: If you're using the simple alert by just specifying // " aps:{alert:"alert msg here"} ", this will work fine. // But if you're using a complex alert with Localization keys, etc., // your "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"))) { alert = (aps[new NSString("alert")] as NSString).ToString(); } //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) { //Manually show an alert if (!string.IsNullOrEmpty(alert)) { var alertController = UIAlertController.Create("Notificiation", alert, UIAlertControllerStyle.Alert); Window?.RootViewController.PresentViewController(alertController, true, null); } } } }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); if (NotificationsSupported) { UNUserNotificationCenter.Current.RequestAuthorization( UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound, (approvalGranted, error) => { if (approvalGranted && error == null) { RegisterForRemoteNotifications(); } }); } Bootstrap.Begin(() => new DeviceInstallationService( () => _deviceToken, () => NotificationsSupported, () => GetNotificationsSupportError())); LoadApplication(new App()); using (var userInfo = options?.ObjectForKey( UIApplication.LaunchOptionsRemoteNotificationKey) as NSDictionary) ProcessNotificationActions(userInfo); return(base.FinishedLaunching(app, options)); }
/// <summary> /// Extract a DateTime object from a NSUrl object /// </summary> /// <param name="url">The url of the file</param> /// <returns> /// 1. The current date as a Nullable<DateTime> object IF url == null /// 2. The date (as a Nullable<DateTime> object) that exists within the file's metadata (pointed to by url) IFF the EXIF data exists /// 3. Null if the date cannot be found within the file's metadata /// </returns> private DateTime?GetDate(NSUrl url) { DateTime dateTaken; // If the provided url is null // NOTE: This case will happen if we import from camera if (url == null) { dateTaken = DateTime.Now; return(dateTaken); } CGImageSource source = CGImageSource.FromUrl(url); NSDictionary ns = new NSDictionary(); NSDictionary properties = source.CopyProperties(ns, 0); NSDictionary exifDict = properties?.ObjectForKey(ImageIO.CGImageProperties.ExifDictionary) as NSDictionary; if (exifDict != null) { NSString date = exifDict[ImageIO.CGImageProperties.ExifDateTimeOriginal] as NSString; if (!string.IsNullOrEmpty(date) && DateTime.TryParseExact(date, "yyyy:MM:dd HH:mm:ss", CultureInfo.CurrentCulture, DateTimeStyles.None, out dateTaken)) { return(dateTaken); } } return(null); }
public static void ProcessNotification (NSDictionary options, bool fromFinishedLaunching) { //Check to see if the dictionary has the aps key. This is the notification payload you would have sent if (options.ContainsKey (new NSString (Resources.Communication.ApsRootElement))) { //Get the aps dictionary var aps = options.ObjectForKey (new NSString (Resources.Communication.ApsRootElement)) as NSDictionary; string alert = string.Empty; string sound = string.Empty; int badge = -1; //Extract the alert text //NOTE: If you're using the simple alert by just specifying " aps:{alert:"alert msg here"} " // this will work fine. But if you're using a complex alert with Localization keys, etc., your "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 (Resources.Communication.ApsAlertElement))) { //alert = (aps [new NSString (Resources.Communication.ApsAlertElement)] as NSString).ToString (); alert = aps.ObjectForKey (new NSString (Resources.Communication.ApsAlertElement)).ToString (); } //Extract the sound string if (aps.ContainsKey (new NSString (Resources.Communication.ApsSoundElement))) { //sound = (aps [new NSString (Resources.Communication.ApsSoundElement)] as NSString).ToString (); sound = aps.ObjectForKey (new NSString (Resources.Communication.ApsSoundElement)).ToString (); } //Extract the badge if (aps.ContainsKey (new NSString (Resources.Communication.ApsBadgeElement))) { //string badgeStr = (aps [new NSString (Resources.Communication.ApsBadgeElement)] as NSString).ToString (); string badgeStr = aps.ObjectForKey (new NSString (Resources.Communication.ApsBadgeElement)).ToString (); int.TryParse (badgeStr, out badge); } //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) { //Manually set the badge in case this came from a remote notification sent while the app was open if (badge >= 0) UIApplication.SharedApplication.ApplicationIconBadgeNumber = badge; /* //Manually play the sound if (!string.IsNullOrEmpty (sound)) { //This assumes that in your json payload you sent the sound filename (like sound.caf) // and that you've included it in your project directory as a Content Build type. var soundObj = MonoTouch.AudioToolbox.SystemSound.FromFile (sound); soundObj.PlaySystemSound (); } */ //Manually show an alert if (!string.IsNullOrEmpty (alert)) { using (UIAlertView avAlert = new UIAlertView ("Notification", alert, null, "OK", null)) { avAlert.Show (); } } } } }
/* * [Export("application:didReceiveRemoteNotification:fetchCompletionHandler:")] * public void DidReceiveRemoteNotification (UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler) { * // This method is part of iOS 7.0 new remote notification support. * // This method is invoked if your Entitlements list the "remote-notification" background operation is set, and you receive a remote notification. * // Upon completion, you must notify the operating system of the result of the method by invoking the provided callback. * // Important: failure to call the provided callback method with the result code before this method completes will cause your application to be terminated. * log ("DidReceiveRemoteNotification: processing data..." ); * processNotification(userInfo, false, application.ApplicationState); * } */ /// <summary> /// Processes the notification. /// </summary> /// <param name="options">Options.</param> /// <param name="fromFinishedLaunching">True if this method comes from the 'FinishedLaunching' delegated method</param> /// <param name="applicationState">The application state that received the remote notification</param> public static void processNotification(NSDictionary options, bool fromFinishedLaunching, UIApplicationState applicationState) { try { #if DEBUG log("******* Checking for PUSH NOTIFICATION data in launch options - fromFinishedLaunching=" + fromFinishedLaunching + ". application state: " + applicationState); #endif if (options != null) { if (fromFinishedLaunching) { NSDictionary remoteNotif = (NSDictionary)options.ObjectForKey(UIApplication.LaunchOptionsRemoteNotificationKey); ProcessRemoteNotification(remoteNotif, fromFinishedLaunching, applicationState); } else { ProcessRemoteNotification(options, fromFinishedLaunching, applicationState); } } else { #if DEBUG log("******* NO launch options"); #endif } } catch (System.Exception ex) { #if DEBUG log("******* Unhandled exception when trying to process notification. fromFinishedLaunching[" + fromFinishedLaunching + "]. Exception message: " + ex.Message); #endif } }
void ProcessNotificationActions(NSDictionary userInfo) { if (userInfo == null) { return; } NSString actionKey = null; NSString actionValue = null; try { actionValue = userInfo.ObjectForKey(actionKey = new NSString("action")) as NSString; if (!string.IsNullOrWhiteSpace(actionValue?.Description)) { NotificationActionService.TriggerAction(actionValue.Description); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { actionKey?.Dispose(); actionValue?.Dispose(); } }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { ServiceLocator.Instance.Add<IDatabase, Database>(); Globe.SharedInstance.Database.InitializeDatabase(); int userid = (int)NSUserDefaults.StandardUserDefaults.IntForKey("iduser"); string username = NSUserDefaults.StandardUserDefaults.StringForKey("username"); string password = NSUserDefaults.StandardUserDefaults.StringForKey("password"); if (!String.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password) && userid != 0) { Globe.SharedInstance.User.username = username; Globe.SharedInstance.User.password = password; Globe.SharedInstance.User.idUser = userid; createTabBarController(); Window.RootViewController = TabBarController; Window.MakeKeyAndVisible(); } SDImageCache.SharedImageCache.ClearMemory(); SDImageCache.SharedImageCache.ClearDisk(); StartTickNotification(); if (launchOptions != null && launchOptions.ObjectForKey(UIApplication.LaunchOptionsRemoteNotificationKey) != null && TabBarController != null) { TabBarController.SelectedIndex = 1; } return true; }
/* [Export("application:didReceiveRemoteNotification:fetchCompletionHandler:")] public void DidReceiveRemoteNotification (UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler) { // This method is part of iOS 7.0 new remote notification support. // This method is invoked if your Entitlements list the "remote-notification" background operation is set, and you receive a remote notification. // Upon completion, you must notify the operating system of the result of the method by invoking the provided callback. // Important: failure to call the provided callback method with the result code before this method completes will cause your application to be terminated. log ("DidReceiveRemoteNotification: processing data..." ); processNotification(userInfo, false, application.ApplicationState); } */ /// <summary> /// Processes the notification. /// </summary> /// <param name="options">Options.</param> /// <param name="fromFinishedLaunching">True if this method comes from the 'FinishedLaunching' delegated method</param> /// <param name="applicationState">The application state that received the remote notification</param> public static void processNotification(NSDictionary options, bool fromFinishedLaunching, UIApplicationState applicationState) { try { #if DEBUG log ("******* Checking for PUSH NOTIFICATION data in launch options - fromFinishedLaunching="+fromFinishedLaunching+". application state: "+ applicationState); #endif if (options != null) { if (fromFinishedLaunching) { NSDictionary remoteNotif = (NSDictionary)options.ObjectForKey (UIApplication.LaunchOptionsRemoteNotificationKey); ProcessRemoteNotification (remoteNotif, fromFinishedLaunching, applicationState); } else { ProcessRemoteNotification (options, fromFinishedLaunching, applicationState); } } else { #if DEBUG log ("******* NO launch options"); #endif } } catch (System.Exception ex) { #if DEBUG log ("******* Unhandled exception when trying to process notification. fromFinishedLaunching[" + fromFinishedLaunching + "]. Exception message: " + ex.Message); #endif } }
void ProcessNotification(NSDictionary userInfo) { if (userInfo == null) { return; } Console.WriteLine("Received Notification"); var apsKey = new NSString("aps"); if (userInfo.ContainsKey(apsKey)) { var alertKey = new NSString("alert"); var aps = (NSDictionary)userInfo.ObjectForKey(apsKey); if (aps.ContainsKey(alertKey)) { var alert = (NSString)aps.ObjectForKey(alertKey); homeViewController.ProcessNotification(alert); Console.WriteLine("Notification: " + alert); } } }
void ProcessNotification(NSDictionary options, bool fromFinishedLaunching) { // make sure we have a payload if (options != null && options.ContainsKey(new NSString("aps"))) { // get the APS dictionary and extract message payload. Message JSON will be converted // into a NSDictionary so more complex payloads may require more processing NSDictionary aps = options.ObjectForKey(new NSString("aps")) as NSDictionary; string payload = string.Empty; NSString payloadKey = new NSString("alert"); if (aps.ContainsKey(payloadKey)) { payload = aps[payloadKey].ToString(); } if (!string.IsNullOrWhiteSpace(payload)) { (App.Current.MainPage as MainPage)?.AddMessage(payload); } } else { Debug.WriteLine($"Received request to process notification but there was no payload."); } }
private void ProcessNotification(NSDictionary options, bool fromFinishedLoading) { if (!(options != null && options.ContainsKey(new NSString("aps")))) { // Short circuit - nothing to do return; } NSDictionary aps = options.ObjectForKey(new NSString("aps")) as NSDictionary; if (!fromFinishedLoading) { var alertString = GetStringFromOptions(aps, "alert"); // Manually show an alert if (!string.IsNullOrEmpty(alertString)) { var pictureString = GetStringFromOptions(aps, "picture"); // Show an alert } var opString = GetStringFromOptions(aps, "op"); if (!string.IsNullOrEmpty(opString) && opString.Equals("sync")) { var syncMessage = new PushToSync() { Table = GetStringFromOptions(aps, "table"), Id = GetStringFromOptions(aps, "id") }; MessagingCenter.Send <PushToSync>(syncMessage, "ItemsChanged"); } } }
public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context) { if (keyPath.ToString() == "bounds") { var frame = ((NSValue)change.ObjectForKey(NSObject.ChangeNewKey)).CGRectValue; if (frame.Width != Width) { Width = frame.Width; var handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs("Width")); } } if (frame.Height != Height) { Height = frame.Height; var handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs("Height")); } } } }
/// <summary> /// Tos the local notification. /// </summary> /// <returns>The local notification.</returns> /// <param name="userInfo">User info.</param> public static LocalNotification ToLocalNotification(this NSDictionary userInfo) { var notification = new LocalNotification(); if (null != userInfo && userInfo.ContainsKey(new NSString("aps"))) { NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary; NSDictionary alert = null; if (aps.ContainsKey(new NSString("alert"))) { alert = aps.ObjectForKey(new NSString("alert")) as NSDictionary; } if (alert != null) { notification.Title = (alert[new NSString("title")] as NSString).ToString(); notification.SubTitle = (alert[new NSString("subtitle")] as NSString).ToString(); notification.Message = (alert[new NSString("body")] as NSString).ToString(); if (aps.ContainsKey(new NSString("badge"))) { var cnt = (alert[new NSString("badge")] as NSString).ToString(); notification.Badge = int.Parse(cnt); } } } return(notification); }
private void ProcessNotification(NSDictionary userInfo) { if (userInfo == null) { return; } Console.WriteLine("Received Notification"); var apsKey = new NSString("aps"); if (userInfo.ContainsKey(apsKey)) { var alertKey = new NSString("alert"); var aps = (NSDictionary)userInfo.ObjectForKey(apsKey); if (aps.ContainsKey(alertKey)) { var alert = (NSString)aps.ObjectForKey(alertKey); var uiAlertView = new UIAlertView($"{AboutThisApp.AppName} Update", alert, null, "OK", null); try { uiAlertView.Show(); } catch (Exception) { // ignored } Console.WriteLine("Notification: " + alert); } } }
public static Conversation ConversationWithDictionary(NSDictionary dictionary) { var photoValues = (NSArray)dictionary.ObjectForKey(new NSString("photos")); var photos = new NSMutableArray(photoValues.Count); for (nint i = 0; i < (nint)photoValues.Count; i++) { var photo = Photo.PhotoWithDictionary(photoValues.GetItem <NSDictionary> (i)); photos.Add(photo); } return(new Conversation { Name = (NSString)dictionary.ObjectForKey(new NSString("name")), Photos = photos }); }
public static BeaconInfo BeaconInfoForUIDFrameData(NSDictionary advertisementFrameList, NSData telemetry, int rssi) { var frameData = advertisementFrameList.ObjectForKey(CBUUID.FromString("FEAA")) as NSData; if (frameData.Length > 1) { var frameBytes = frameData.ToArray(); if (frameBytes[0] != EddystoneUIDFrameTypeID) { System.Diagnostics.Debug.WriteLine("Unexpected non UID Frame passed to BeaconInfoForUIDFrameData."); return(null); } else if (frameBytes.Length < 18) { System.Diagnostics.Debug.WriteLine("Frame Data for UID Frame unexpectedly truncated in BeaconInfoForUIDFrameData."); } var txPower = Convert.ToInt32(frameBytes[1]); var beaconID = new byte [frameBytes.Length - 2]; Array.Copy(frameBytes, 2, beaconID, 0, beaconID.Length); var bid = new BeaconID(BeaconType.Eddystone, beaconID); return(new BeaconInfo(bid, txPower, rssi, telemetry)); } return(null); }
public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, System.IntPtr context) { if (keyPath.ToString() == "transform") { this.Transform = ((NSValue)change.ObjectForKey(NSObject.ChangeNewKey)).CGAffineTransformValue; } }
private void InitPushNotification(NSDictionary options) { try { int notificationHub = 1; if (notificationHub == 0) { // Check if App was opened by Push Notification. var keyName = new NSString("UIApplicationLaunchOptionsRemoteNotificationKey"); if (options != null && options.Keys != null && options.Keys.Length != 0 && options.ContainsKey(keyName)) { NSDictionary pushOptions = options.ObjectForKey(keyName) as NSDictionary; //ProcessPushNotification(pushOptions, false); } } else { var settings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(settings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); } } catch (Exception e) { } }
public override void ReceivedRemoteNotification (UIApplication application, NSDictionary userInfo) { var message = (NSString) userInfo.ObjectForKey (new NSString ("aps")).ValueForKey(new NSString("alert")); var alert = new UIAlertView("Notification", message, null, "Okay", null); alert.Show (); }
public override void HandleResult(FBRequest request, NSDictionary dict) { if (dict.ObjectForKey(new NSString("owner")) != null) { } else { NSObject id = dict.ObjectForKey(new NSString("pid")); if(IsWallPhoto) { _controller.TagPhoto(id.ToString()); } else { _controller.SetProfilePicture(id.ToString()); } } }
public AppDelegate () { PrepareCache (); ExtractImages (); controller = new MonodocDocumentController (); // Some UI feature we use rely on Lion or better, so special case it try { var version = new NSDictionary ("/System/Library/CoreServices/SystemVersion.plist"); var osxVersion = Version.Parse (version.ObjectForKey (new NSString ("ProductVersion")).ToString ()); isOnLion = osxVersion.Major == 10 && osxVersion.Minor >= 7; } catch {} // Load documentation var args = Environment.GetCommandLineArgs (); IEnumerable<string> extraDocs = null, extraUncompiledDocs = null; if (args != null && args.Length > 1) { var extraDirs = args.Skip (1); extraDocs = extraDirs .Where (d => d.StartsWith ("+")) .Select (d => d.Substring (1)) .Where (d => Directory.Exists (d)); extraUncompiledDocs = extraDirs .Where (d => d.StartsWith ("@")) .Select (d => d.Substring (1)) .Where (d => Directory.Exists (d)); } if (extraUncompiledDocs != null) foreach (var dir in extraUncompiledDocs) RootTree.UncompiledHelpSources.Add (dir); Root = RootTree.LoadTree (null); if (extraDocs != null) foreach (var dir in extraDocs) Root.AddSource (dir); var macDocPath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "macdoc"); if (!Directory.Exists (macDocPath)) Directory.CreateDirectory (macDocPath); var helpSources = Root.HelpSources .Cast<HelpSource> () .Where (hs => !string.IsNullOrEmpty (hs.BaseFilePath) && !string.IsNullOrEmpty (hs.Name)) .Select (hs => Path.Combine (hs.BaseFilePath, hs.Name + ".zip")) .Where (File.Exists); IndexUpdateManager = new IndexUpdateManager (helpSources, macDocPath); BookmarkManager = new BookmarkManager (macDocPath); AppleDocHandler = new AppleDocHandler ("/Library/Frameworks/Mono.framework/Versions/Current/etc/"); // Configure the documentation rendering. SettingsHandler.Settings.EnableEditing = false; SettingsHandler.Settings.preferred_font_size = 200; HelpSource.use_css = true; }
public virtual void AddEntriesFromDictionary(NSDictionary otherDictionary) { NSEnumerator enumerator = otherDictionary.KeyEnumerator(); id aKey = null; while ( (aKey = enumerator.NextObject()) != null) { id value = otherDictionary.ObjectForKey(aKey); this.SetObjectForKey(value, aKey); } }
public static AAPLUser UserWithDictionary (NSDictionary dictionary) { string name = (NSString)dictionary.ObjectForKey (new NSString ("name")); var conversationDictionaries = (NSArray)dictionary.ObjectForKey (new NSString ("conversations")); var conversations = new NSMutableArray (conversationDictionaries.Count); for (int i = 0; i < conversationDictionaries.Count; i++) { var conversation = AAPLConversation.ConversationWithDictionary (conversationDictionaries.GetItem<NSDictionary> (i)); conversations.Add (conversation); } var lastPhotoDictionary = NSDictionary.FromDictionary ((NSDictionary)dictionary.ObjectForKey (new NSString ("lastPhoto"))); return new AAPLUser { Name = name, Conversations = conversations, LastPhoto = AAPLPhoto.PhotoWithDictionary (lastPhotoDictionary) }; }
public override void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info) { UIImage image = (UIImage)info.ObjectForKey(new NSString("UIImagePickerControllerOriginalImage")); // do whatever else you'd like to with the image Console.WriteLine("media {0} x {1}", image.CGImage.Width, image.CGImage.Height); picker.DismissModalViewControllerAnimated(true); _imageView.Image = image; if (_popover != null && _popover.PopoverVisible) _popover.Dismiss(true); }
public override void DidReceiveRemoteNotification (UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler) { var message = (userInfo.ObjectForKey (new NSString (Const.APS_DICT_KEY)) as NSDictionary) [Const.ALERT_DICT_KEY].ToString (); if (application.ApplicationState != UIApplicationState.Active || message.Contains ("parking spot")) { //TODO needs a better way to identify pushes that need reply var objectId = userInfo [Const.OBJECT_ID].ToString (); parkApp.OnNotificationReceived (objectId); } else { if (!string.IsNullOrWhiteSpace (message)) { App.DisplayAlertAsync (message); } } }
public override void ObserveValue (NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context) { //base.ObserveValue (keyPath, ofObject, change, context); if (!firstLocationUpdate) { // If the first location update has not yet been recieved, then jump to that // location. firstLocationUpdate = true; var location = change.ObjectForKey (NSValue.ChangeNewKey) as CLLocation; mapView.Camera = CameraPosition.FromCamera (location.Coordinate, 14); } }
public override void DidCaptureScreenWithContext(WTArchitectView architectView, NSDictionary context) { string intString = context.ObjectForKey(new NSString("kWTScreenshotSaveModeKey")).ToString(); int resultCode = int.Parse (intString); if (WTScreenshotSaveMode._Delegate == (Wikitude.Architect.WTScreenshotSaveMode)resultCode) { UIImage image = (UIImage)context[(new NSString("kWTScreenshotImageKey"))]; postImageOnFacebook (image); } else { showPhotoLibraryAlert (); } }
public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler) { NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary; string alert = string.Empty; if (aps.ContainsKey(new NSString("alert"))) alert = (aps [new NSString("alert")] as NSString).ToString(); //show alert if (!string.IsNullOrEmpty(alert)) { UIAlertView avAlert = new UIAlertView("Notification", alert, null, "OK", null); avAlert.Show(); } }
public override void HandleAction(UIApplication application, string actionIdentifier, NSDictionary remoteNotificationInfo, NSDictionary responseInfo, Action completionHandler) { Console.WriteLine ("Response: {0}", responseInfo.ObjectForKey((NSString)"UIUserNotificationActionResponseTypedTextKey")); NotificarePushLib.Shared ().HandleActionForNotificationWithData ((NSString)actionIdentifier, remoteNotificationInfo, responseInfo, (NSDictionary info) => { Console.WriteLine ("HandleAction info: {0}", info); completionHandler(); }, (NSError error) => { Console.WriteLine ("HandleAction error: {0}", error); completionHandler(); } ); }
/// <summary> /// Recursive version of LoadDefautSetings /// </summary> private static void LoadSettingsFile(NSDictionary settings) { bool foundTypeKey; bool foundDefaultValue; string prefKeyName; NSObject prefDefaultValue; NSObject key; // get the preference specifiers node NSArray prefs = settings.ObjectForKey(new NSString("PreferenceSpecifiers")) as NSArray; // loop through the settings for(uint i = 0; i < prefs.Count; i++) { // reset for each setting foundTypeKey = false; foundDefaultValue = false; prefKeyName = string.Empty; prefDefaultValue = new NSObject(); NSDictionary pref = new NSDictionary(prefs.ValueAt(i)); // loop through the dictionary of any particular setting for(uint keyCount = 0; keyCount < pref.Keys.Length; keyCount++) { // shortcut reference key = pref.Keys[keyCount]; // get the key name and default value if(key.ToString() == "Key") { foundTypeKey = true; prefKeyName = pref[key].ToString(); } else if(key.ToString() == "DefaultValue") { foundDefaultValue = true; prefDefaultValue = pref[key]; } else if(key.ToString() == "File") { NSDictionary nestedSettings = NSDictionary.FromFile(NSBundle.MainBundle.BundlePath + "/Settings.bundle/" + pref[key].ToString() + ".plist"); LoadSettingsFile(nestedSettings); } // if we've found both, set it in our user preferences if(foundTypeKey && foundDefaultValue) { NSUserDefaults.StandardUserDefaults[prefKeyName] = prefDefaultValue; } } } }
async public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo) { if (null != userInfo && userInfo.ContainsKey(new NSString("aps"))) { NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary; string alert = string.Empty; if (aps.ContainsKey(new NSString("alert"))) { var nsString = aps[new NSString("alert")] as NSString; if (nsString != null) alert = nsString.ToString(); } if (!string.IsNullOrEmpty(alert)) { //Show a pop-up if the application is open UIAlertView avAlert = new UIAlertView("CRM Item", alert, null, "OK", null); avAlert.Show(); BandClient client = MainViewController.GetClient(); //Connect to Band if not already connected if (client == null) { try { BandClientManager manager = MainViewController.GetManager(); client = manager.AttachedClients.FirstOrDefault(); if (client == null) return; client = MainViewController.GetClient(); } catch (BandException) { } } if (client == null) return; //Send to Band await client.NotificationManager.SendMessageTaskAsync(MainViewController.GetTileId(), "CRM Item", alert, DateTime.Now, true); } } }
void ProcessNotification(NSDictionary options, bool fromFinishedLaunching) { if (null != options && options.ContainsKey(new NSString("aps"))) { NSDictionary aps = options.ObjectForKey(new NSString("aps")) as NSDictionary; string alert = string.Empty; if (aps.ContainsKey(new NSString("alert"))) alert = (aps[new NSString("alert")] as NSString).ToString(); if (!fromFinishedLaunching) { if (!string.IsNullOrEmpty(alert)) { UIAlertView avAlert = new UIAlertView("Notification", alert, null, "OK", null); avAlert.Show(); } } } }
private void BlockForAlbumProcessing (NSUrlRequest request, NSHttpUrlResponse response, NSDictionary json) { NSArray data = (NSArray)json.ObjectForKey (new NSString("shots")); var photos = new List<PhotoInfo> (); for (var x = 0; x < data.Count; x++) { var photo = new NSDictionary (data.ValueAt((uint)x)); // Gather the high-quality photo information. var originalImageSource = (NSString)photo.ObjectForKey (new NSString("image_url")); var thumbnailImageSource = (NSString)photo.ObjectForKey (new NSString("image_teaser_url")); var width = (NSNumber)photo.ObjectForKey (new NSString("width")); var height = (NSNumber)photo.ObjectForKey (new NSString("height")); // We gather the highest-quality photo's dimensions so that we can size the thumbnails // correctly until the high-quality image is downloaded. var dimensions = new SizeF (width.Int32Value, height.Int32Value); photos.Add (new PhotoInfo{ OriginalSource = originalImageSource.ToString(), ThumbnailSoruce = thumbnailImageSource.ToString(), Dimensions = dimensions }); } _photos = photos; if(ScrubberIsEnabled) LoadThumbnails (); _albumDataSource.Photos = _photos; _scrubberDataSource.Photos = _photos; PhotoAlbumView.ReloadData (); if (PhotoScrubberView != null) PhotoScrubberView.ReloadData (); RefreshChromeState (); }
internal static bool fetch(NSDictionary dict, NSString key, ref ulong b) { var k = dict.ObjectForKey (key) as NSNumber; if (k == null) return false; b = k.UInt64Value; return true; }
public static NSFileAttributes FromDict(NSDictionary dict) { if (dict == null) return null; var ret = new NSFileAttributes (); bool b = false; if (fetch (dict, NSFileManager.AppendOnly, ref b)) ret.AppendOnly = b; if (fetch (dict, NSFileManager.Busy, ref b)) ret.Busy = b; if (fetch (dict, NSFileManager.Immutable, ref b)) ret.Immutable = b; //if (fetch (dict, NSFileManager.ProtectedFile, ref b)) //ret.ProtectedFile = b; if (fetch (dict, NSFileManager.ExtensionHidden, ref b)) ret.FileExtensionHidden = b; var date = dict.ObjectForKey (NSFileManager.CreationDate) as NSDate; if (date != null) ret.CreationDate = date; date = dict.ObjectForKey (NSFileManager.ModificationDate) as NSDate; if (date != null) ret.ModificationDate = date; var name = dict.ObjectForKey (NSFileManager.OwnerAccountName) as NSString; if (name != null) ret.OwnerAccountName = name.ToString (); uint u = 0; if (fetch (dict, NSFileManager.DeviceIdentifier, ref u)) ret.DeviceIdentifier = u; if (fetch (dict, NSFileManager.GroupOwnerAccountID, ref u)) ret.FileGroupOwnerAccountID = u; if (fetch (dict, NSFileManager.OwnerAccountID, ref u)) ret.FileOwnerAccountID = u; if (fetch (dict, NSFileManager.HfsTypeCode, ref u)) ret.HfsTypeCode = u; if (fetch (dict, NSFileManager.PosixPermissions, ref u)) ret.PosixPermissions = u; if (fetch (dict, NSFileManager.ReferenceCount, ref u)) ret.FileReferenceCount = u; if (fetch (dict, NSFileManager.SystemFileNumber, ref u)) ret.FileSystemFileNumber = u; ulong l = 0; if (fetch (dict, NSFileManager.Size, ref l)) ret.FileSize = l; return ret; }
void ProcessNotification (NSDictionary options, bool fromFinishedLaunching) { // Check to see if the dictionary has the aps key. This is the notification payload you would have sent if (null != options && options.ContainsKey (new NSString ("aps"))) { //Get the aps dictionary NSDictionary aps = options.ObjectForKey (new NSString ("aps")) as NSDictionary; string command = string.Empty; //Extract the alert text // NOTE: If you're using the simple alert by just specifying // " aps:{alert:"alert msg here"} ", this will work fine. // But if you're using a complex alert with Localization keys, etc., // your "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 ("command"))) { command = (aps [new NSString ("command")] as NSString).ToString (); } //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) { //Manually show an alert if (!string.IsNullOrEmpty (command)) { if (command == RemoteCommands.Alert) { UIAlertView avAlert = new UIAlertView ("Notification", "Alert", null, "OK", null); avAlert.Show (); } else if (command == RemoteCommands.RefreshConferences) { Messenger.Default.Send (new ConferenceAddedMessage ()); } else if (command == RemoteCommands.RefreshSchedule) { Messenger.Default.Send (new ConferenceAddedToScheduleMessage ()); } } } } }
public override void ObserveValue (NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context) { if (context == RateObservationContext.Handle) { //TODO: need debug here. float newRate = ((NSNumber)change.ObjectForKey (NSObject.ChangeNewKey)).FloatValue; var oldRateNum = change.ObjectForKey (NSObject.ChangeOldKey); if (oldRateNum.GetType () == typeof(NSNumber) && newRate != ((NSNumber)oldRateNum).FloatValue) { playing = (newRate != 0.0f || playRateToRestore != 0.0f); updatePlayPauseButton (); updateScrubber (); updateTimeLabel (); } } else if (context == StatusObservationContext.Handle) { AVPlayerItem playerItem = ofObject as AVPlayerItem; if (playerItem.Status == AVPlayerItemStatus.ReadyToPlay) { /* Once the AVPlayerItem becomes ready to play, i.e. [playerItem status] == AVPlayerItemStatusReadyToPlay, its duration can be fetched from the item. */ addTimeObserverToPlayer (); } else if (playerItem.Status == AVPlayerItemStatus.Failed) { reportError (playerItem.Error); } } else { base.ObserveValue (keyPath, ofObject, change, context); } }