protected virtual void CheckNSObjectProtocol(NSObject obj) { // not documented to allow null, but commonly used this way. OTOH it's not clear what code answer this // (it might be different implementations) but we can make sure that Apple allows null with this test // ref: https://bugzilla.xamarin.com/show_bug.cgi?id=35924 var kind_of_null = obj.IsKindOfClass(null); if (kind_of_null) { ReportError("{0} : IsKindOfClass(null) failed", instance_type_name); } var is_member_of_null = obj.IsMemberOfClass(null); if (is_member_of_null) { ReportError("{0} : IsMemberOfClass(null) failed", instance_type_name); } var respond_to_null = obj.RespondsToSelector(null); if (respond_to_null) { ReportError("{0} : RespondToSelector(null) failed", instance_type_name); } var conforms_to_null = obj.ConformsToProtocol(IntPtr.Zero); if (conforms_to_null) { ReportError("{0} : ConformsToProtocol(null) failed", instance_type_name); } }
public void ReceivedRemoteNotification(NSDictionary userInfo) { string message = null; NSObject aps = userInfo.ObjectForKey(new NSString("aps")); if (aps != null && aps.IsKindOfClass(new Class(typeof(NSDictionary)))) { var dict = (NSDictionary)aps; NSObject alert = dict.ObjectForKey(new NSString("alert")); if (alert != null && alert.IsKindOfClass(new Class(typeof(NSString)))) { message = alert.ToString(); } } if (message != null) { BusinessProcessContext.Current.GlobalEventsController.OnPushMessage(message); } else { _applicaitonContext.HandleException(new NonFatalException(D.PUSH_NOTIFICATION_ERROR, userInfo.ToString())); } }