From eb539ac5e61d2c03c72cac4d0b4c7247a940a289 Mon Sep 17 00:00:00 2001 From: Bryce Cogswell Date: Fri, 24 Jul 2020 22:42:59 -0700 Subject: [PATCH] Support gomaposm.com associated domain --- src/apple-app-site-association | 13 +++++++++++++ src/iOS/AppDelegate.m | 9 +++++++++ src/iOS/Go Map!!.xcodeproj/project.pbxproj | 2 ++ src/iOS/Go Map!!/Go Map!!.entitlements | 3 ++- src/iOS/URLParsing/LocationURLParser.m | 6 ++++-- 5 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 src/apple-app-site-association diff --git a/src/apple-app-site-association b/src/apple-app-site-association new file mode 100644 index 000000000..8c477d025 --- /dev/null +++ b/src/apple-app-site-association @@ -0,0 +1,13 @@ +{ + "applinks": { + "apps": [], + "details": [ + { + "appIDs": [ "MKTTC6734C.com.bryceco.GoMap" ], + "paths": [ + NOT "/help" + ] + } + ] + } +} diff --git a/src/iOS/AppDelegate.m b/src/iOS/AppDelegate.m index d1b6899ca..44aeccf22 100644 --- a/src/iOS/AppDelegate.m +++ b/src/iOS/AppDelegate.m @@ -65,6 +65,15 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( return YES; } +- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler +{ + if ( [userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb] ) { + NSURL * url = userActivity.webpageURL; + return [self application:application openURL:url options:@{}]; + } + return NO; +} + /** Makes sure that the user defaults do not contain plaintext credentials from previous app versions. */ diff --git a/src/iOS/Go Map!!.xcodeproj/project.pbxproj b/src/iOS/Go Map!!.xcodeproj/project.pbxproj index 1618bd8a8..07b970f65 100644 --- a/src/iOS/Go Map!!.xcodeproj/project.pbxproj +++ b/src/iOS/Go Map!!.xcodeproj/project.pbxproj @@ -234,6 +234,7 @@ 024C323C1DEEA97100AD62AB /* AdvancedSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdvancedSettingsViewController.m; sourceTree = ""; }; 024CAB2524429C8200EFB7CA /* ContactUsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContactUsViewController.h; sourceTree = ""; }; 024CAB2624429C8200EFB7CA /* ContactUsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ContactUsViewController.m; sourceTree = ""; }; + 024E6D2E24CBBCE500E1E2A3 /* apple-app-site-association */ = {isa = PBXFileReference; lastKnownFileType = text; name = "apple-app-site-association"; path = "../apple-app-site-association"; sourceTree = ""; }; 025224E616D7292E00B6FD53 /* RotatingNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RotatingNavigationController.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 025224E716D7292E00B6FD53 /* RotatingNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = RotatingNavigationController.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 0259E4061BCAEC88006C354C /* MyApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MyApplication.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; @@ -534,6 +535,7 @@ isa = PBXGroup; children = ( 02BACD22205A1DDB00C74A49 /* Go Map!!.entitlements */, + 024E6D2E24CBBCE500E1E2A3 /* apple-app-site-association */, 02ACBA3916713CCB00BB4414 /* Go Map! */, 64348CEB225E7CD900ADE7FB /* GoMapTests */, 64348D09225EA24E00ADE7FB /* GoMapUITests */, diff --git a/src/iOS/Go Map!!/Go Map!!.entitlements b/src/iOS/Go Map!!/Go Map!!.entitlements index 22d48909f..3e188b357 100644 --- a/src/iOS/Go Map!!/Go Map!!.entitlements +++ b/src/iOS/Go Map!!/Go Map!!.entitlements @@ -4,7 +4,8 @@ com.apple.developer.associated-domains - applinks:openstreetmap.org + applinks:gomaposm.com + applinks:www.gomaposm.com com.apple.security.app-sandbox diff --git a/src/iOS/URLParsing/LocationURLParser.m b/src/iOS/URLParsing/LocationURLParser.m index a50d32e8e..455f19c6d 100644 --- a/src/iOS/URLParsing/LocationURLParser.m +++ b/src/iOS/URLParsing/LocationURLParser.m @@ -45,12 +45,14 @@ - (MapLocation *)parseURL:(NSURL *)url return parserResult; } - if ( [url.absoluteString hasPrefix:@"gomaposm://?"] ) { + NSURLComponents * urlComponents = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO]; + + // https://gomaposm.com/edit?center=47.679056,-122.212559&zoom=21&view=aerial%2Beditor + if ( [url.absoluteString hasPrefix:@"gomaposm://?"] || [urlComponents.host isEqualToString:@"gomaposm.com"] ) { BOOL hasCenter = NO, hasZoom = NO; double lat = 0, lon = 0, zoom = 0; MapViewState view = MAPVIEW_NONE; - NSURLComponents * urlComponents = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO]; for ( NSURLQueryItem * queryItem in urlComponents.queryItems ) { if ( [queryItem.name isEqualToString:@"center"] ) {