Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 7837aae

Browse files
authored
Merge pull request #687 from vstostap/push-notification-broadcast-security
limit the components that Intent will resolve to
2 parents b40f9b5 + 240a24b commit 7837aae

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,12 @@ public void sendToNotificationCentre(Bundle bundle) {
360360

361361
Intent actionIntent = new Intent(context, intentClass);
362362
actionIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
363-
actionIntent.setAction(context.getPackageName() + "." + action);
363+
actionIntent.setAction(packageName + "." + action);
364364

365365
// Add "action" for later identifying which button gets pressed.
366366
bundle.putString("action", action);
367367
actionIntent.putExtra("notification", bundle);
368+
actionIntent.setPackage(packageName);
368369

369370
PendingIntent pendingActionIntent = PendingIntent.getActivity(context, notificationID, actionIntent,
370371
PendingIntent.FLAG_UPDATE_CURRENT);

android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationRegistrationService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ protected void onHandleIntent(Intent intent) {
3131
}
3232

3333
private void sendRegistrationToken(String token) {
34-
Intent intent = new Intent(this.getPackageName() + ".RNPushNotificationRegisteredToken");
34+
String packageName = this.getPackageName();
35+
Intent intent = new Intent(packageName + ".RNPushNotificationRegisteredToken");
3536
intent.putExtra("token", token);
37+
intent.setPackage(packageName);
3638
sendBroadcast(intent);
3739
}
3840
}

0 commit comments

Comments
 (0)