谷歌地图应用程序无法打开。打开不相关的应用

时间:2017-01-31 12:19:44

标签: ios objective-c google-maps

我希望打开谷歌地图方向应用程序,如果它在那里我想在Safari浏览器中打开它。但我发现意外的行为是..而不是打开谷歌地图,它打开我的设备中安装的我的其他应用程序。

我用的代码。

if ([[UIApplication sharedApplication] canOpenURL:
     [NSURL URLWithString:@"comgooglemaps://"]]) {
    NSString *urlSring = [NSString stringWithFormat:@"comgooglemaps://?saddr=%f,%f&daddr=%f,%f",[IDUserDetails getUserCurrentLocation].latitude,[IDUserDetails getUserCurrentLocation].longitude,
                          deedModelShared.deedModel.deedCoordinate.latitude, deedModelShared.deedModel.deedCoordinate.longitude];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlSring] options:@{} completionHandler:^(BOOL success) {

    }];

} else {
    NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f",
                     [IDUserDetails getUserCurrentLocation].latitude,[IDUserDetails getUserCurrentLocation].longitude,
                     deedModelShared.deedModel.deedCoordinate.latitude, deedModelShared.deedModel.deedCoordinate.longitude];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url] options:@{} completionHandler:^(BOOL success) {

    }];
}

url scheme

<key>LSApplicationQueriesSchemes</key>
<array>
 <string>comgooglemaps</string>
</array>

0 个答案:

没有答案