File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
mParticle-Apple-SDK/AppNotifications Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -84,4 +84,19 @@ - (void)testOpenURLOptions {
8484 [appNotificationHandler openURL: url options: options];
8585}
8686
87+ - (void )testContinueUserActivityNoCrash {
88+ MPAppNotificationHandler *appNotificationHandler = [MParticle sharedInstance ].appNotificationHandler ;
89+
90+ NSUserActivity *userActivity = [[NSUserActivity alloc ] initWithActivityType: @" test" ];
91+ userActivity.webpageURL = [[NSURL alloc ] initWithString: @" http://mparticle.com" ];
92+ [appNotificationHandler continueUserActivity: userActivity restorationHandler: ^(NSArray <id <UIUserActivityRestoring>> *restorationHandler){}];
93+ }
94+
95+ - (void )testContinueUserActivityWithNilURLNoCrash {
96+ MPAppNotificationHandler *appNotificationHandler = [MParticle sharedInstance ].appNotificationHandler ;
97+
98+ NSUserActivity *userActivity = [[NSUserActivity alloc ] initWithActivityType: @" test" ];
99+ [appNotificationHandler continueUserActivity: userActivity restorationHandler: ^(NSArray <id <UIUserActivityRestoring>> *restorationHandler){}];
100+ }
101+
87102@end
Original file line number Diff line number Diff line change @@ -281,7 +281,12 @@ - (BOOL)continueUserActivity:(nonnull NSUserActivity *)userActivity restorationH
281281 return NO ;
282282 }
283283
284- stateMachine.launchInfo = [[MPLaunchInfo alloc ] initWithURL: userActivity.webpageURL options: nil ];
284+ if (userActivity.webpageURL != nil ) {
285+ stateMachine.launchInfo = [[MPLaunchInfo alloc ] initWithURL: userActivity.webpageURL options: nil ];
286+ } else {
287+ NSURL *defaultURL = [[NSURL alloc ] initWithString: @" " ];
288+ stateMachine.launchInfo = [[MPLaunchInfo alloc ] initWithURL: defaultURL options: nil ];
289+ }
285290
286291 SEL continueUserActivitySelector = @selector (continueUserActivity:restorationHandler: );
287292
You can’t perform that action at this time.
0 commit comments