Adds support for copying and opening deep link URLs
This commit is contained in:
parent
5282265fd5
commit
f5f09f22d4
@ -134,6 +134,7 @@
|
||||
BFB359452278FD8100CFD920 /* N64DeltaCore_RSP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BFB359422278FD6800CFD920 /* N64DeltaCore_RSP.framework */; };
|
||||
BFB359462278FD8100CFD920 /* N64DeltaCore_RSP.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BFB359422278FD6800CFD920 /* N64DeltaCore_RSP.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
BFBAB2E31EB685A2004E0B0E /* DeltaCoreProtocol+Delta.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFBAB2E21EB685A2004E0B0E /* DeltaCoreProtocol+Delta.swift */; };
|
||||
BFC1F2CC22F9515F00606A45 /* CopyDeepLinkActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFC1F2CB22F9515F00606A45 /* CopyDeepLinkActivity.swift */; };
|
||||
BFC3628021ADE2BA00EF2BE6 /* UIAlertController+Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFC3627F21ADE2BA00EF2BE6 /* UIAlertController+Error.swift */; };
|
||||
BFC6F7B81F435BC500221B96 /* Input+Display.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFC6F7B71F435BC500221B96 /* Input+Display.swift */; };
|
||||
BFC9B7391CEFCD34008629BB /* CheatsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFC9B7381CEFCD34008629BB /* CheatsViewController.swift */; };
|
||||
@ -314,6 +315,7 @@
|
||||
BFB359422278FD6800CFD920 /* N64DeltaCore_RSP.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = N64DeltaCore_RSP.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BFBAB2E21EB685A2004E0B0E /* DeltaCoreProtocol+Delta.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DeltaCoreProtocol+Delta.swift"; sourceTree = "<group>"; };
|
||||
BFC134E01AAD82460087AD7B /* SNESDeltaCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = SNESDeltaCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BFC1F2CB22F9515F00606A45 /* CopyDeepLinkActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopyDeepLinkActivity.swift; sourceTree = "<group>"; };
|
||||
BFC3627F21ADE2BA00EF2BE6 /* UIAlertController+Error.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIAlertController+Error.swift"; sourceTree = "<group>"; };
|
||||
BFC6F7B71F435BC500221B96 /* Input+Display.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Input+Display.swift"; sourceTree = "<group>"; };
|
||||
BFC9B7381CEFCD34008629BB /* CheatsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CheatsViewController.swift; sourceTree = "<group>"; };
|
||||
@ -462,6 +464,7 @@
|
||||
children = (
|
||||
BF525EE91FF6CD12004AA849 /* DeepLink.swift */,
|
||||
BF525EE71FF5F370004AA849 /* DeepLinkController.swift */,
|
||||
BFC1F2CB22F9515F00606A45 /* CopyDeepLinkActivity.swift */,
|
||||
);
|
||||
path = "Deep Linking";
|
||||
sourceTree = "<group>";
|
||||
@ -1035,6 +1038,7 @@
|
||||
BFAA1FED1B8AA4FA00495943 /* Settings.swift in Sources */,
|
||||
BFA0D1271D3AE1F600565894 /* GameViewController.swift in Sources */,
|
||||
BF59428A1E09BC8B0051894B /* _SaveState.swift in Sources */,
|
||||
BFC1F2CC22F9515F00606A45 /* CopyDeepLinkActivity.swift in Sources */,
|
||||
BF5942801E09BC830051894B /* SaveState.swift in Sources */,
|
||||
BF59428E1E09BCFB0051894B /* ImportController.swift in Sources */,
|
||||
BF13A7581D5D2FD9000BB055 /* EmulatorCore+Cheats.swift in Sources */,
|
||||
|
||||
@ -111,6 +111,10 @@ extension AppDelegate
|
||||
{
|
||||
return DropboxService.shared.handleDropboxURL(url)
|
||||
}
|
||||
else if url.scheme?.lowercased() == "delta"
|
||||
{
|
||||
return self.deepLinkController.handle(.url(url))
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
53
Delta/Deep Linking/CopyDeepLinkActivity.swift
Normal file
53
Delta/Deep Linking/CopyDeepLinkActivity.swift
Normal file
@ -0,0 +1,53 @@
|
||||
//
|
||||
// CopyDeepLinkActivity.swift
|
||||
// Delta
|
||||
//
|
||||
// Created by Riley Testut on 8/5/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
extension UIActivity.ActivityType
|
||||
{
|
||||
static let copyDeepLink = UIActivity.ActivityType("com.rileytestut.Delta.CopyDeepLink")
|
||||
}
|
||||
|
||||
class CopyDeepLinkActivity: UIActivity
|
||||
{
|
||||
override class var activityCategory: UIActivity.Category {
|
||||
return .action
|
||||
}
|
||||
|
||||
override var activityType: UIActivity.ActivityType? {
|
||||
return .copyDeepLink
|
||||
}
|
||||
|
||||
override var activityTitle: String? {
|
||||
return NSLocalizedString("Copy Deep Link", comment: "")
|
||||
}
|
||||
|
||||
override var activityImage: UIImage? {
|
||||
return UIImage(named: "Link")
|
||||
}
|
||||
|
||||
override func canPerform(withActivityItems activityItems: [Any]) -> Bool
|
||||
{
|
||||
if activityItems.contains(where: { $0 is Game })
|
||||
{
|
||||
return true
|
||||
}
|
||||
else
|
||||
{
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
override func prepare(withActivityItems activityItems: [Any])
|
||||
{
|
||||
guard let game = activityItems.first(where: { $0 is Game }) as? Game else { return }
|
||||
|
||||
let deepLink = URL(action: .launchGame(identifier: game.identifier))
|
||||
UIPasteboard.general.url = deepLink
|
||||
}
|
||||
}
|
||||
@ -12,16 +12,12 @@ extension URL
|
||||
{
|
||||
init(action: DeepLink.Action)
|
||||
{
|
||||
var components = URLComponents()
|
||||
components.host = action.type.rawValue
|
||||
|
||||
switch action
|
||||
{
|
||||
case .launchGame(let identifier): components.path = identifier
|
||||
case .launchGame(let identifier):
|
||||
let deepLinkURL = URL(string: "delta://\(action.type.rawValue)/\(identifier)")!
|
||||
self = deepLinkURL
|
||||
}
|
||||
|
||||
let url = components.url!
|
||||
self = url
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -585,7 +585,9 @@ private extension GameCollectionViewController
|
||||
print(error)
|
||||
}
|
||||
|
||||
let activityViewController = UIActivityViewController(activityItems: [symbolicURL], applicationActivities: nil)
|
||||
let copyDeepLinkActivity = CopyDeepLinkActivity()
|
||||
|
||||
let activityViewController = UIActivityViewController(activityItems: [symbolicURL, game], applicationActivities: [copyDeepLinkActivity])
|
||||
activityViewController.completionWithItemsHandler = { (activityType, finished, returnedItems, error) in
|
||||
do
|
||||
{
|
||||
|
||||
@ -149,6 +149,16 @@
|
||||
<string>db-f5btgysf9ma9bb6</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>Delta</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>delta</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>10</string>
|
||||
|
||||
26
Resources/Assets.xcassets/Link.imageset/Contents.json
vendored
Normal file
26
Resources/Assets.xcassets/Link.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "Link@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "Link@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "Link@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
},
|
||||
"properties" : {
|
||||
"template-rendering-intent" : "template"
|
||||
}
|
||||
}
|
||||
BIN
Resources/Assets.xcassets/Link.imageset/Link@1x.png
vendored
Normal file
BIN
Resources/Assets.xcassets/Link.imageset/Link@1x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
Resources/Assets.xcassets/Link.imageset/Link@2x.png
vendored
Normal file
BIN
Resources/Assets.xcassets/Link.imageset/Link@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
BIN
Resources/Assets.xcassets/Link.imageset/Link@3x.png
vendored
Normal file
BIN
Resources/Assets.xcassets/Link.imageset/Link@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.8 KiB |
Loading…
Reference in New Issue
Block a user