Skip to content

Commit

Permalink
Fix for not showing notifications opn android 14. Starting with andro…
Browse files Browse the repository at this point in the history
…id 14 a pending mutable intent that does not specify a component or package will cause an exception. Switching to immutable intends for the CustomtabsIntent and declaring the package context for the mutable reply intent.
  • Loading branch information
freeflyk committed May 5, 2024
1 parent b85bfae commit 0857f10
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ static private PendingIntent getReplyIntent(Context context,
String[] link = rawNotification.getString("link").split("/"); // use provided link to extract talk chatroom id
intent.putExtra("talk_chatroom", CommonUtil.cleanUpURLParams(link[link.length-1]));
intent.putExtra("talk_link", CommonUtil.cleanUpURLParams(rawNotification.getString("link")));
intent.setPackage(context.getPackageName()); // Issue 78 --> https://developer.android.com/about/versions/14/behavior-changes-14?hl=en#safer-intents

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
return PendingIntent.getBroadcast(
context,
notification_id,
intent,
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
);
}else{
return PendingIntent.getBroadcast(
Expand Down

0 comments on commit 0857f10

Please sign in to comment.