Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace 0 by PendingIntent.FLAG_IMMUTABLE for Android>12 comptatibility #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions android/src/main/java/com/react/SmsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ public void send(String addresses, String text, final Callback errorCallback, fi
JSONArray addressList = jsonObject.getJSONArray("addressList");
int n;
if ((n = addressList.length()) > 0) {
PendingIntent sentIntent = PendingIntent.getBroadcast(mActivity, 0, new Intent("SENDING_SMS"), 0);
PendingIntent sentIntent = PendingIntent.getBroadcast(mActivity, 0, new Intent("SENDING_SMS"), PendingIntent.FLAG_IMMUTABLE);
SmsManager sms = SmsManager.getDefault();
for (int i = 0; i < n; i++) {
String address;
if ((address = addressList.optString(i)).length() > 0)
sms.sendTextMessage(address, null, text, sentIntent, null);
}
} else {
PendingIntent sentIntent = PendingIntent.getActivity(mActivity, 0, new Intent("android.intent.action.VIEW"), 0);
PendingIntent sentIntent = PendingIntent.getActivity(mActivity, 0, new Intent("android.intent.action.VIEW"), PendingIntent.FLAG_IMMUTABLE);
Intent intent = new Intent("android.intent.action.VIEW");
intent.putExtra("sms_body", text);
intent.setData(Uri.parse("sms:"));
Expand Down Expand Up @@ -241,8 +241,8 @@ public void autoSend(String phoneNumber, String message, final Callback errorCal
ArrayList<PendingIntent> sentPendingIntents = new ArrayList<PendingIntent>();
ArrayList<PendingIntent> deliveredPendingIntents = new ArrayList<PendingIntent>();

PendingIntent sentPI = PendingIntent.getBroadcast(context, 0, new Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(context, 0, new Intent(DELIVERED), 0);
PendingIntent sentPI = PendingIntent.getBroadcast(context, 0, new Intent(SENT), PendingIntent.FLAG_IMMUTABLE);
PendingIntent deliveredPI = PendingIntent.getBroadcast(context, 0, new Intent(DELIVERED), PendingIntent.FLAG_IMMUTABLE);

//---when the SMS has been sent---
context.registerReceiver(new BroadcastReceiver() {
Expand Down