rae*_*aed 10 ios ios14 apple-appclips
当我设计我的 App Clip Launch 体验时,我考虑到 App 只能通过QR code、NFC或触发App Clip Code。这就是为什么我将应用启动链接到具有特定 ID 的特定位置。
当我的应用程序上周上线时,当我尝试扫描 NFC 标签时,应用程序每次都按预期启动。
现在,如果我点击主屏幕上的 App Clip 图标,应用程序将使用扫描的最后一个 URL 启动。
这对我不起作用!所以我正在寻找一种方法来检查应用程序是通过扫描还是点击启动的?我尝试记录应用程序启动,但它始终通过扫描 (NFC) 或图标点击按顺序运行:
AppDelegate.didFinishLaunchingWithOptions()
SceneDelegate.willConnectTo() // It's here where I am handling the Universal Link
Run Code Online (Sandbox Code Playgroud)
如何检查用户是否通过点击或扫描启动了应用程序?知道应用程序总是在点击图标时模拟通用启动链接!
或者如何查找已保存的 URL?我试图获取所有UserDefaults和一些Keychain数据,但我什么也没找到!
我遇到了同样的问题!不幸的是,\xe2\x80\x99s 没有办法:
\nUserDefaults从或检索缓存数据Keychain苹果在其人机界面指南中明确表示,如果您想支持多个业务,您应该添加位置服务因素!
\n\n\n考虑多种业务。一个 App Clip 可以为许多不同的\n企业或拥有多个位置的企业提供支持。在这两种情况下,人们最终可能会一次将 App Clip 用于多个业务或位置。App Clip 必须处理此用例\n并相应地更新其用户界面。例如,考虑一种在 App Clip 内\n最近的商家或位置之间进行切换的方法,\n并在用户启动时验证用户\xe2\x80\x99 的位置。
\n
So, now your tags for specific location should be mapped to a coordinates [Longitude, Latitude]. Apple has introduced a new location verification API just for App Clips that allows you to do a one-time check to see if the App Clip code, NFC tag or QR code that the user scanned is where it says it is.
Enable Your App Clip to Verify the User\xe2\x80\x99s Location\nTo enable your App Clip to verify the user\xe2\x80\x99s location, modify your App Clip\xe2\x80\x99s Info.plist file:
Info.plist, add the NSAppClip key, and set its\ntype to Dictionary.NSAppClipRequestLocationConfirmation as the key, select Boolean as\nits type, and set its value to true.But using App Clip Location services is different:
\nactivity.appClipActivationPayload to confirm if the location (in Step 2) is in region where the user is right now.The Code bellow (Copied from Apple) explains how to do it.
\nimport UIKit\nimport AppClip\nimport CoreLocation\n\nclass SceneDelegate: UIResponder, UIWindowSceneDelegate {\n \n var window: UIWindow?\n \n // Call the verifyUserLocation(_:) function in all applicable life-cycle callbacks.\n\n func verifyUserLocation(_ activity: NSUserActivity?) {\n \n // Guard against faulty data.\n guard activity != nil else { return }\n guard activity!.activityType == NSUserActivityTypeBrowsingWeb else { return }\n guard let payload = activity!.appClipActivationPayload else { return }\n guard let incomingURL = activity?.webpageURL else { return }\n\n // Create a CLRegion object.\n guard let region = location(from: incomingURL) else {\n // Respond to parsing errors here.\n return\n }\n \n // Verify that the invocation happened at the expected location.\n payload.confirmAcquired(in: region) { (inRegion, error) in\n guard let confirmationError = error as? APActivationPayloadError else {\n if inRegion {\n // The location of the NFC tag matches the user\'s location.\n } else {\n // The location of the NFC tag doesn\'t match the records;\n // for example, if someone moved the NFC tag.\n }\n return\n }\n \n if confirmationError.code == .doesNotMatch {\n // The scanned URL wasn\'t registered for the App Clip.\n } else {\n // The user denied location access, or the source of the\n // App Clip\xe2\x80\x99s invocation wasn\xe2\x80\x99t an NFC tag or visual code.\n }\n }\n }\n\n func location(from url:URL) -> CLRegion? {\n \n // You should retrieve the coordinates from your Database\n let coordinates = CLLocationCoordinate2D(latitude: 37.334722,\n longitude: 122.008889)\n return CLCircularRegion(center: coordinates,\n radius: 100,\n identifier: "Apple Park")\n }\n}\nRun Code Online (Sandbox Code Playgroud)\nAnd that\xe2\x80\x99s it, this his how your support multiple businesses with App Clip
\n| 归档时间: |
|
| 查看次数: |
340 次 |
| 最近记录: |