Skip to content

Commit

Permalink
prevent fatal crashes when launching App Clips (#47000)
Browse files Browse the repository at this point in the history
Summary:
App Clips are full of bugs. One such bug is how launching an App Clip from Test Flight (and perhaps other systems) will cause the user activity to be of type `NSUserActivityTypeBrowsingWeb` but with a nullish `userActivity.webpageURL` (even though it's typed as never being nullish in this mode).

## Changelog:

[IOS] [FIXED] - Fix launching App Clips with nullish URLs.

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: #47000

Test Plan:
The following was failing cryptically and required extensive debugging to get launching.

https://github.com/user-attachments/assets/ffd26297-b20b-45a2-97cc-35a48b740cb2

Reviewed By: cipolleschi

Differential Revision: D64372170

Pulled By: lunaleaps

fbshipit-source-id: 388f05530f3bccdd9b446382931f127421bc8a27
  • Loading branch information
EvanBacon authored and facebook-github-bot committed Oct 15, 2024
1 parent f9460de commit 043e2fe
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ + (BOOL)application:(UIApplication *)application
continueUserActivity:(NSUserActivity *)userActivity
restorationHandler:(nonnull void (^)(NSArray<id<UIUserActivityRestoring>> *_Nullable))restorationHandler
{
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
// This can be nullish when launching an App Clip.
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb] && userActivity.webpageURL != nil) {
NSDictionary *payload = @{@"url" : userActivity.webpageURL.absoluteString};
[[NSNotificationCenter defaultCenter] postNotificationName:kOpenURLNotification object:self userInfo:payload];
}
Expand Down

0 comments on commit 043e2fe

Please sign in to comment.