如何从ios中的谷歌地图返回本地应用程序 [英] How to return native app from google map in ios

查看:102
本文介绍了如何从ios中的谷歌地图返回本地应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在从下面的代码开始从原生应用程序的谷歌地图现在我想从谷歌地图返回到ios原生应用程序。我该如何做到这一点。如果([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@comgooglemaps://]]

I am opening google map from native app by below code now i want to return from google map to ios native app.How can i do this. Thanks in advance.

    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps://"]]) {
 NSString *url=[NSString stringWithFormat:@"comgooglemaps-x-callback://?saddr=28.458125,77.033833&daddr=18.407000,73.506300&directionsmode=driving&x-success=sourceapp://?resume=true&x-source=lavasa"];
 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];

   }


推荐答案

有关URL方案的 Google地图文档部分,有一个示例,说明callbackl应该如何工作。

In the Google Maps Documentation section about the URL scheme there is an example of how the callbackl should work.



  • x-source 应用程序发送x回调请求。
    简称是首选。

  • x-success - 完成时要调用的URL。
    通常这将是您自己应用程序的URL方案,允许用户将
    返回到原始应用程序。
  • x-source The name of the application sending the x-callback request. Short names are preferred.
  • x-success — The URL to call when complete. Often this will be a URL scheme for your own app, allowing users to return to the original application.

例如:

For example:

comgooglemaps-x-callback://?center=40.765819,-73.975866&zoom=14
   &x-success=sourceapp://?resume=true
   &x-source=SourceApp

在这里您可以看到 x-success 属性,该属性应该设置为您的应用程序URL方案, x-source 是Google地图应用中显示的应用名称,返回到应用栏。

Here you see the x-success property, which should be set to your app URL scheme and the x-source is the name of your app as presented in Google Maps app return to app bar.

这篇关于如何从ios中的谷歌地图返回本地应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆