Notification Hub Redirection in IOS

Hello Developers,

i'm using xamarin forms
The app works great - the app registers for push notifications, and push notifications are received successfully from Azure Notification Hubs on iOS and Android

i did some research. i found the same question and the response was for android only
link : https://forums.xamarin.com/discussion/40352/how-to-go-to-specific-page-when-user-clicks-on-push-notification

how do I get my app to launch into or display a specific page when the user taps on a push notification on IOS,
Thank you.

Best Answers

  • soufianemarlysoufianemarly ✭✭
    Accepted Answer

    Thank you @LandLu i was able to redirect to a specific page using MessagingCenter

        public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
        {
            NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary;
            string title = string.Empty;
            if (aps.ContainsKey(new NSString("alert")))
                title = (aps[new NSString("title")] as NSString).ToString();
    
            string value = userInfo["title"] as NSString;
            Console.WriteLine("VALUE --> " + value);
    
            if (title is "EVENTS")
            {
                Console.WriteLine("EVENTS SELECTED GO TO AGENDA");
                MessagingCenter.Send(Xamarin.Forms.Application.Current, "goToAgenda", new WeekViewPage());
            }
            else if (title is "ABSENCES")
            {
                Console.WriteLine("ABSENCES SELECTED GO TO ABSENCES");
    
                MessagingCenter.Send(Xamarin.Forms.Application.Current, "goToAbsence", new AbsencePage());
    
            }
            else if (title is "OTHERS")
            {
                Console.WriteLine("OTHERS SELECTED GO TO EVALUATION");
    
                MessagingCenter.Send(Xamarin.Forms.Application.Current, "goToEvents", true);
            }
            else if (title is "MARKS")
            {
                Console.WriteLine("MARKS SELECTED GO TO EVALUATION");
    
                MessagingCenter.Send(Xamarin.Forms.Application.Current, "goToEvaluation", new EvaluationPage());
    
            }
            Console.WriteLine("ReceivedRemoteNotification");
    
    
            ProcessNotification(userInfo, false);
        }
    

Answers

  • soufianemarlysoufianemarly Member ✭✭
    Accepted Answer

    Thank you @LandLu i was able to redirect to a specific page using MessagingCenter

        public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
        {
            NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary;
            string title = string.Empty;
            if (aps.ContainsKey(new NSString("alert")))
                title = (aps[new NSString("title")] as NSString).ToString();
    
            string value = userInfo["title"] as NSString;
            Console.WriteLine("VALUE --> " + value);
    
            if (title is "EVENTS")
            {
                Console.WriteLine("EVENTS SELECTED GO TO AGENDA");
                MessagingCenter.Send(Xamarin.Forms.Application.Current, "goToAgenda", new WeekViewPage());
            }
            else if (title is "ABSENCES")
            {
                Console.WriteLine("ABSENCES SELECTED GO TO ABSENCES");
    
                MessagingCenter.Send(Xamarin.Forms.Application.Current, "goToAbsence", new AbsencePage());
    
            }
            else if (title is "OTHERS")
            {
                Console.WriteLine("OTHERS SELECTED GO TO EVALUATION");
    
                MessagingCenter.Send(Xamarin.Forms.Application.Current, "goToEvents", true);
            }
            else if (title is "MARKS")
            {
                Console.WriteLine("MARKS SELECTED GO TO EVALUATION");
    
                MessagingCenter.Send(Xamarin.Forms.Application.Current, "goToEvaluation", new EvaluationPage());
    
            }
            Console.WriteLine("ReceivedRemoteNotification");
    
    
            ProcessNotification(userInfo, false);
        }
    
Sign In or Register to comment.