Skip to content

Commit

Permalink
Support gomaposm.com associated domain
Browse files Browse the repository at this point in the history
  • Loading branch information
bryceco committed Jul 25, 2020
1 parent 60f2846 commit eb539ac
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/apple-app-site-association
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"applinks": {
"apps": [],
"details": [
{
"appIDs": [ "MKTTC6734C.com.bryceco.GoMap" ],
"paths": [
NOT "/help"
]
}
]
}
}
9 changes: 9 additions & 0 deletions src/iOS/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> * _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.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/iOS/Go Map!!.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
024C323C1DEEA97100AD62AB /* AdvancedSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdvancedSettingsViewController.m; sourceTree = "<group>"; };
024CAB2524429C8200EFB7CA /* ContactUsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContactUsViewController.h; sourceTree = "<group>"; };
024CAB2624429C8200EFB7CA /* ContactUsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ContactUsViewController.m; sourceTree = "<group>"; };
024E6D2E24CBBCE500E1E2A3 /* apple-app-site-association */ = {isa = PBXFileReference; lastKnownFileType = text; name = "apple-app-site-association"; path = "../apple-app-site-association"; sourceTree = "<group>"; };
025224E616D7292E00B6FD53 /* RotatingNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RotatingNavigationController.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
025224E716D7292E00B6FD53 /* RotatingNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = RotatingNavigationController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
0259E4061BCAEC88006C354C /* MyApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MyApplication.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
Expand Down Expand Up @@ -534,6 +535,7 @@
isa = PBXGroup;
children = (
02BACD22205A1DDB00C74A49 /* Go Map!!.entitlements */,
024E6D2E24CBBCE500E1E2A3 /* apple-app-site-association */,
02ACBA3916713CCB00BB4414 /* Go Map! */,
64348CEB225E7CD900ADE7FB /* GoMapTests */,
64348D09225EA24E00ADE7FB /* GoMapUITests */,
Expand Down
3 changes: 2 additions & 1 deletion src/iOS/Go Map!!/Go Map!!.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:openstreetmap.org</string>
<string>applinks:gomaposm.com</string>
<string>applinks:www.gomaposm.com</string>
</array>
<key>com.apple.security.app-sandbox</key>
<true/>
Expand Down
6 changes: 4 additions & 2 deletions src/iOS/URLParsing/LocationURLParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"] ) {
Expand Down

0 comments on commit eb539ac

Please sign in to comment.