Skip to content

Commit

Permalink
fix: crash on non-textinput action (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
Naturalclar authored Oct 26, 2020
1 parent 3700819 commit af8e98e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ios/RNCPushNotificationIOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ @implementation RNCPushNotificationIOS
}

API_AVAILABLE(ios(10.0))
static NSDictionary *RCTFormatOpenedUNNotification(UNTextInputNotificationResponse *response)
static NSDictionary *RCTFormatOpenedUNNotification(UNNotificationResponse *response)
{
UNNotification* notification = response.notification;
NSMutableDictionary *formattedResponse = [RCTFormatUNNotification(notification) mutableCopy];
Expand All @@ -269,10 +269,15 @@ @implementation RNCPushNotificationIOS
NSMutableDictionary *userInfo = [content.userInfo mutableCopy];
userInfo[@"userInteraction"] = [NSNumber numberWithInt:1];
userInfo[@"actionIdentifier"] = response.actionIdentifier;


formattedResponse[@"userInfo"] = RCTNullIfNil(RCTJSONClean(userInfo));
formattedResponse[@"actionIdentifier"] = RCTNullIfNil(response.actionIdentifier);
formattedResponse[@"userText"] = RCTNullIfNil(response.userText);

NSString* userText = [response isKindOfClass:[UNTextInputNotificationResponse class]] ? ((UNTextInputNotificationResponse *)response).userText : nil;
if (userText) {
formattedResponse[@"userText"] = RCTNullIfNil(userText);
}

return formattedResponse;
}
Expand Down

0 comments on commit af8e98e

Please sign in to comment.