Migrate iOS and Android to use pushRouteInformation (#39372)

* Migrate iOS and Android to use pushRouteInformation

* revert

* fix test
diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java
index 56db871..d22118d 100644
--- a/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java
+++ b/shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java
@@ -829,11 +829,13 @@
   void onNewIntent(@NonNull Intent intent) {
     ensureAlive();
     if (flutterEngine != null) {
-      Log.v(TAG, "Forwarding onNewIntent() to FlutterEngine and sending pushRoute message.");
+      Log.v(
+          TAG,
+          "Forwarding onNewIntent() to FlutterEngine and sending pushRouteInformation message.");
       flutterEngine.getActivityControlSurface().onNewIntent(intent);
       String initialRoute = maybeGetInitialRouteFromIntent(intent);
       if (initialRoute != null && !initialRoute.isEmpty()) {
-        flutterEngine.getNavigationChannel().pushRoute(initialRoute);
+        flutterEngine.getNavigationChannel().pushRouteInformation(initialRoute);
       }
     } else {
       Log.w(TAG, "onNewIntent() invoked before FlutterFragment was attached to an Activity.");
diff --git a/shell/platform/android/io/flutter/embedding/engine/systemchannels/NavigationChannel.java b/shell/platform/android/io/flutter/embedding/engine/systemchannels/NavigationChannel.java
index 87e7e36..36cac70 100644
--- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/NavigationChannel.java
+++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/NavigationChannel.java
@@ -11,6 +11,8 @@
 import io.flutter.plugin.common.JSONMethodCodec;
 import io.flutter.plugin.common.MethodCall;
 import io.flutter.plugin.common.MethodChannel;
+import java.util.HashMap;
+import java.util.Map;
 
 /** TODO(mattcarroll): fill in javadoc for NavigationChannel. */
 public class NavigationChannel {
@@ -43,6 +45,13 @@
     channel.invokeMethod("pushRoute", route);
   }
 
+  public void pushRouteInformation(@NonNull String route) {
+    Log.v(TAG, "Sending message to push route information '" + route + "'");
+    Map<String, String> message = new HashMap<>();
+    message.put("location", route);
+    channel.invokeMethod("pushRouteInformation", message);
+  }
+
   public void popRoute() {
     Log.v(TAG, "Sending message to pop route.");
     channel.invokeMethod("popRoute", null);
diff --git a/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java b/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java
index 45c1c2e..e120d77 100644
--- a/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java
+++ b/shell/platform/android/test/io/flutter/embedding/android/FlutterActivityAndFragmentDelegateTest.java
@@ -726,7 +726,7 @@
   }
 
   @Test
-  public void itSendsPushRouteMessageWhenOnNewIntent() {
+  public void itSendsPushRouteInformationMessageWhenOnNewIntent() {
     when(mockHost.shouldHandleDeeplinking()).thenReturn(true);
     // Create the real object that we're testing.
     FlutterActivityAndFragmentDelegate delegate = new FlutterActivityAndFragmentDelegate(mockHost);
@@ -742,11 +742,11 @@
 
     // Verify that the navigation channel was given the push route message.
     verify(mockFlutterEngine.getNavigationChannel(), times(1))
-        .pushRoute("/custom/route?query=test");
+        .pushRouteInformation("/custom/route?query=test");
   }
 
   @Test
-  public void itDoesNotSendPushRouteMessageWhenOnNewIntentIsNonHierarchicalUri() {
+  public void itDoesNotSendPushRouteInformationMessageWhenOnNewIntentIsNonHierarchicalUri() {
     when(mockHost.shouldHandleDeeplinking()).thenReturn(true);
     // Create the real object that we're testing.
     FlutterActivityAndFragmentDelegate delegate = new FlutterActivityAndFragmentDelegate(mockHost);
@@ -764,11 +764,12 @@
     delegate.onNewIntent(mockIntent);
 
     // Verify that the navigation channel was not given a push route message.
-    verify(mockFlutterEngine.getNavigationChannel(), times(0)).pushRoute("mailto:test@test.com");
+    verify(mockFlutterEngine.getNavigationChannel(), times(0))
+        .pushRouteInformation("mailto:test@test.com");
   }
 
   @Test
-  public void itSendsPushRouteMessageWhenOnNewIntentWithQueryParameterAndFragment() {
+  public void itSendsPushRouteInformationMessageWhenOnNewIntentWithQueryParameterAndFragment() {
     when(mockHost.shouldHandleDeeplinking()).thenReturn(true);
     // Create the real object that we're testing.
     FlutterActivityAndFragmentDelegate delegate = new FlutterActivityAndFragmentDelegate(mockHost);
@@ -785,11 +786,11 @@
 
     // Verify that the navigation channel was given the push route message.
     verify(mockFlutterEngine.getNavigationChannel(), times(1))
-        .pushRoute("/custom/route?query=test#fragment");
+        .pushRouteInformation("/custom/route?query=test#fragment");
   }
 
   @Test
-  public void itSendsPushRouteMessageWhenOnNewIntentWithFragmentNoQueryParameter() {
+  public void itSendsPushRouteInformationMessageWhenOnNewIntentWithFragmentNoQueryParameter() {
     when(mockHost.shouldHandleDeeplinking()).thenReturn(true);
     // Create the real object that we're testing.
     FlutterActivityAndFragmentDelegate delegate = new FlutterActivityAndFragmentDelegate(mockHost);
@@ -804,11 +805,12 @@
     delegate.onNewIntent(mockIntent);
 
     // Verify that the navigation channel was given the push route message.
-    verify(mockFlutterEngine.getNavigationChannel(), times(1)).pushRoute("/custom/route#fragment");
+    verify(mockFlutterEngine.getNavigationChannel(), times(1))
+        .pushRouteInformation("/custom/route#fragment");
   }
 
   @Test
-  public void itSendsPushRouteMessageWhenOnNewIntentNoQueryParameter() {
+  public void itSendsPushRouteInformationMessageWhenOnNewIntentNoQueryParameter() {
     when(mockHost.shouldHandleDeeplinking()).thenReturn(true);
     // Create the real object that we're testing.
     FlutterActivityAndFragmentDelegate delegate = new FlutterActivityAndFragmentDelegate(mockHost);
@@ -823,7 +825,8 @@
     delegate.onNewIntent(mockIntent);
 
     // Verify that the navigation channel was given the push route message.
-    verify(mockFlutterEngine.getNavigationChannel(), times(1)).pushRoute("/custom/route");
+    verify(mockFlutterEngine.getNavigationChannel(), times(1))
+        .pushRouteInformation("/custom/route");
   }
 
   @Test
diff --git a/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm b/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm
index 9e0c86f..abc1bd8 100644
--- a/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm
+++ b/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm
@@ -157,8 +157,11 @@
                        if ([url.fragment length] != 0) {
                          fullRoute = [NSString stringWithFormat:@"%@#%@", fullRoute, url.fragment];
                        }
-                       [flutterViewController.engine.navigationChannel invokeMethod:@"pushRoute"
-                                                                          arguments:fullRoute];
+                       [flutterViewController.engine.navigationChannel
+                           invokeMethod:@"pushRouteInformation"
+                              arguments:@{
+                                @"location" : fullRoute,
+                              }];
                      }
                    }];
       return YES;
diff --git a/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm
index 33b4e42..035b726 100644
--- a/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm
+++ b/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm
@@ -67,8 +67,8 @@
                             openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
                             options:@{}];
   XCTAssertTrue(result);
-  OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRoute"
-                                           arguments:@"/custom/route?query=test"]);
+  OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRouteInformation"
+                                           arguments:@{@"location" : @"/custom/route?query=test"}]);
 }
 
 - (void)testLaunchUrlWithDeepLinkingNotSet {
@@ -104,8 +104,9 @@
           openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test#fragment"]
           options:@{}];
   XCTAssertTrue(result);
-  OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRoute"
-                                           arguments:@"/custom/route?query=test#fragment"]);
+  OCMVerify([self.mockNavigationChannel
+      invokeMethod:@"pushRouteInformation"
+         arguments:@{@"location" : @"/custom/route?query=test#fragment"}]);
 }
 
 - (void)testLaunchUrlWithFragmentNoQueryParameter {
@@ -117,8 +118,8 @@
                             openURL:[NSURL URLWithString:@"http://myApp/custom/route#fragment"]
                             options:@{}];
   XCTAssertTrue(result);
-  OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRoute"
-                                           arguments:@"/custom/route#fragment"]);
+  OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRouteInformation"
+                                           arguments:@{@"location" : @"/custom/route#fragment"}]);
 }
 
 - (void)testReleasesWindowOnDealloc {
@@ -139,7 +140,7 @@
 
 #pragma mark - Deep linking
 
-- (void)testUniversalLinkPushRoute {
+- (void)testUniversalLinkPushRouteInformation {
   OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
       .andReturn(@YES);
 
@@ -151,8 +152,8 @@
         restorationHandler:^(NSArray<id<UIUserActivityRestoring>>* __nullable restorableObjects){
         }];
   XCTAssertTrue(result);
-  OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRoute"
-                                           arguments:@"/custom/route?query=test"]);
+  OCMVerify([self.mockNavigationChannel invokeMethod:@"pushRouteInformation"
+                                           arguments:@{@"location" : @"/custom/route?query=test"}]);
 }
 
 @end