braze-inc / braze-swift-sdk

https://www.braze.com
Other
47 stars 19 forks source link

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

Open p4checo opened 1 week ago

p4checo commented 1 week 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 1 week 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.