Skip to content

Commit af8e98e

Browse files
authored
fix: crash on non-textinput action (#208)
1 parent 3700819 commit af8e98e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ios/RNCPushNotificationIOS.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ @implementation RNCPushNotificationIOS
260260
}
261261

262262
API_AVAILABLE(ios(10.0))
263-
static NSDictionary *RCTFormatOpenedUNNotification(UNTextInputNotificationResponse *response)
263+
static NSDictionary *RCTFormatOpenedUNNotification(UNNotificationResponse *response)
264264
{
265265
UNNotification* notification = response.notification;
266266
NSMutableDictionary *formattedResponse = [RCTFormatUNNotification(notification) mutableCopy];
@@ -269,10 +269,15 @@ @implementation RNCPushNotificationIOS
269269
NSMutableDictionary *userInfo = [content.userInfo mutableCopy];
270270
userInfo[@"userInteraction"] = [NSNumber numberWithInt:1];
271271
userInfo[@"actionIdentifier"] = response.actionIdentifier;
272+
272273

273274
formattedResponse[@"userInfo"] = RCTNullIfNil(RCTJSONClean(userInfo));
274275
formattedResponse[@"actionIdentifier"] = RCTNullIfNil(response.actionIdentifier);
275-
formattedResponse[@"userText"] = RCTNullIfNil(response.userText);
276+
277+
NSString* userText = [response isKindOfClass:[UNTextInputNotificationResponse class]] ? ((UNTextInputNotificationResponse *)response).userText : nil;
278+
if (userText) {
279+
formattedResponse[@"userText"] = RCTNullIfNil(userText);
280+
}
276281

277282
return formattedResponse;
278283
}

0 commit comments

Comments
 (0)