private void OnRaiseUserInfo(UserInfoEventArgs e) { var handler = OnUserInfo; if (handler == null) { return; } Console.WriteLine("Sending out user info event for " + e.Channel + "\n" + e); handler(this, e); }
public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler) { if (NotificationReceived == null) { return; } var e = new UserInfoEventArgs { UserInfo = response.Notification.Request.Content.UserInfo }; NotificationReceived(this, e); }
public void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action <UNNotificationPresentationOptions> completionHandler) { if (NotificationReceived == null) { return; } var e = new UserInfoEventArgs { UserInfo = notification.Request.Content.UserInfo }; NotificationReceived(this, e); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnUserInfoReceived(object sender, UserInfoEventArgs e) { var user = e.Users.Find(x => x.Id == Item.Id); if (user == null) { return; } Item = user; Flag.Image = Flags.Get(user.CountryFlag); SteamManager.SendAvatarRetrievalRequest((ulong)user.SteamId); UpdateContent(Item, Index); }
// To receive notifications in foregroung on iOS 9 and below. // To receive notifications in background in any iOS version public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action <UIBackgroundFetchResult> completionHandler) { // If you are receiving a notification message while your app is in the background, // this callback will not be fired 'till the user taps on the notification launching the application. // If you disable method swizzling, you'll need to call this method. // This lets FCM track message delivery and analytics, which is performed // automatically with method swizzling enabled. //Messaging.GetInstance ().AppDidReceiveMessage (userInfo); if (NotificationReceived == null) { return; } var e = new UserInfoEventArgs { UserInfo = userInfo }; NotificationReceived(this, e); }
// To receive notifications in foreground on iOS 10 devices. [Export("userNotificationCenter:willPresentNotification:withCompletionHandler:")] public void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action<UNNotificationPresentationOptions> completionHandler) { if (NotificationReceived == null) return; var e = new UserInfoEventArgs { UserInfo = notification.Request.Content.UserInfo }; NotificationReceived(this, e); var title = notification.Request.Content.Title; var body = notification.Request.Content.Body; System.Diagnostics.Debug.WriteLine($"---> push title={title} , body{body} " ); } /// WORKAROUND #region Workaround for handling notifications in background for iOS 10 [Export("userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:")] public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler) { if (NotificationReceived == null) return; var e = new UserInfoEventArgs { UserInfo = response.Notification.Request.Content.UserInfo }; NotificationReceived(this, e); System.Diagnostics.Debug.WriteLine("--->get message " + response.Notification.Date); } #endregion /// END OF WORKAROUND void TokenRefreshNotification(object sender, NSNotificationEventArgs e) { // This method will be fired everytime a new token is generated, including the first // time. So if you need to retrieve the token as soon as it is available this is where that // should be done. //var refreshedToken = InstanceId.SharedInstance.Token; ConnectToFCM(); // TODO: If necessary send token to application server. } // To receive notifications in foreground on iOS 10 devices.
// To receive notifications in foregroung on iOS 9 and below. // To receive notifications in background in any iOS version public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler) { // If you are receiving a notification message while your app is in the background, // this callback will not be fired 'till the user taps on the notification launching the application. // If you disable method swizzling, you'll need to call this method. // This lets FCM track message delivery and analytics, which is performed // automatically with method swizzling enabled. //Messaging.GetInstance ().AppDidReceiveMessage (userInfo); if (NotificationReceived == null) return; var e = new UserInfoEventArgs { UserInfo = userInfo }; NotificationReceived(this, e); if (application.ApplicationState == UIApplicationState.Active) { System.Diagnostics.Debug.WriteLine(userInfo); var aps_d = userInfo["aps"] as NSDictionary; var alert_d = aps_d["alert"] as NSDictionary; var body = alert_d["body"] as NSString; var title = alert_d["title"] as NSString; System.Diagnostics.Debug.WriteLine($"---> push title={title} , body{body} "); } } public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)