Skip to content

Commit 7b7893f

Browse files
IvanIvan
Ivan
authored and
Ivan
committed
Add userInteraction attr for user opened push
1 parent 53ba717 commit 7b7893f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ios/RNCPushNotificationIOS.m

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,20 @@ @implementation RNCPushNotificationIOS
125125
return formattedNotification;
126126
}
127127

128+
API_AVAILABLE(ios(10.0))
129+
static NSDictionary *RCTFormatOpenedUNNotification(UNNotification *notification)
130+
{
131+
NSMutableDictionary *formattedNotification = [RCTFormatUNNotification(notification) mutableCopy];
132+
UNNotificationContent *content = notification.request.content;
133+
134+
NSMutableDictionary *userInfo = [content.userInfo mutableCopy];
135+
userInfo[@"userInteraction"] = @"1";
136+
137+
formattedNotification[@"userInfo"] = RCTNullIfNil(RCTJSONClean(userInfo));
138+
139+
return formattedNotification;
140+
}
141+
128142
#endif //TARGET_OS_TV / TARGET_OS_UIKITFORMAC
129143

130144
RCT_EXPORT_MODULE()
@@ -220,7 +234,7 @@ + (void)didReceiveNotificationResponse:(UNNotificationResponse *)response
220234
API_AVAILABLE(ios(10.0)) {
221235
[[NSNotificationCenter defaultCenter] postNotificationName:kLocalNotificationReceived
222236
object:self
223-
userInfo:RCTFormatUNNotification(response.notification)];
237+
userInfo:RCTFormatOpenedUNNotification(response.notification)];
224238
}
225239

226240
- (void)handleLocalNotificationReceived:(NSNotification *)notification

0 commit comments

Comments
 (0)