braze-inc / braze-swift-sdk

Braze SDK for the Apple ecosystem, including: iOS, macOS, iPadOS, visionOS, tvOS
https://www.braze.com
Other
52 stars 19 forks source link

[Bug]: Universal Link forwarding is not filtering URL schema #134

Closed p4checo closed 3 months ago

p4checo commented 4 months ago

Platform

iOS

Platform Version

iOS 17.5.1

Braze SDK Version

8.4.0

Xcode Version

Xcode 15.4

Computer Processor

Apple (M1)

Repro Rate

100% od the time

Steps To Reproduce

  1. have domain applinks:www.mydomain.com in the .entilements file
  2. have myscheme registered as custom schemes in CFBundleURLTypes in Info.plist file
  3. have Braze.Configuration.forwardUniversalLinks = true
  4. send deeplink push notification to device with link myscheme://www.mydomain.com/some-path

Expected Behavior

Braze should forward it as regular URL to the app (i.e. via onOpenURL / application(:open:options:)), as it's not a universal link

Actual Incorrect Behavior

Braze forwards it as a universal link via NSUserActivity (i.e. onContinueUserActivity, application(:continue:restorationHandler:)) which in Release builds crashes the app with:

Fatal Exception: NSInvalidArgumentException NSUserActivity.webpageURL scheme "myscheme" is not allowed.

Verbose Logs

No response

Additional Information

A sanity check should be added so that only http or https schemas are forwarded as universal links via NSUserActivity.

Sending the push with a custom scheme without host (e.g. myscheme:///some-path), the usual/correct™ scenario works fine

jerielng commented 4 months ago

@p4checo Thanks for raising this! We'll take a look into some possible error handling for http and https schemes and see where it might make sense for this feature. To your point, using a different host from the one registered with your universal link is indeed the more prescriptive scenario with scheme-based deeplinks, so if that works for your case for now, we would recommend that approach.

hokstuff commented 3 months ago

Hi @p4checo,

We have released Swift SDK version 10.0.0 which resolves this issue. Let us know if you run into any issues, thanks!