Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,13 @@ public void sendMail(String recepientString, String subject, String body) {
}

@ReactMethod
public void sendText(String text, String type) {
public void sendText(String text, String type, String packageName) {
final Intent sendIntent = this.getSendIntent(text, type);

if (packageName != "") {
sendIntent.setPackage(packageName);
}

//Check that an app exists to receive the intent
if (sendIntent.resolveActivity(this.reactContext.getPackageManager()) != null) {
this.reactContext.runOnUiQueueThread(new Runnable(){
Expand All @@ -349,9 +354,13 @@ public void run(){
}

@ReactMethod
public void sendTextWithTitle(final String title, String text, String type) {
public void sendTextWithTitle(final String title, String text, String type, String packageName) {
final Intent sendIntent = this.getSendIntent(text, type);

if (packageName != "") {
sendIntent.setPackage(packageName);
}

//Check that an app exists to receive the intent
if (sendIntent.resolveActivity(this.reactContext.getPackageManager()) != null) {
this.reactContext.runOnUiQueueThread(new Runnable(){
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ declare namespace SendIntentAndroid {
title: string
text: string
type: TextType
package?: string
}

interface CalendarEventConfig {
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ var SendIntentAndroid = {
TEXT_HTML: Platform.OS === "android" ? RNSendIntentAndroid.TEXT_HTML : "text/html",
sendText(config) {
if ("title" in config && config.title != null && config.title.length > 0) {
RNSendIntentAndroid.sendTextWithTitle(config.title, config.text, config.type || "text/plain");
RNSendIntentAndroid.sendTextWithTitle(config.title, config.text, config.type || "text/plain", config.package || '');
} else {
RNSendIntentAndroid.sendText(config.text, config.type || "text/plain");
RNSendIntentAndroid.sendText(config.text, config.type || "text/plain", config.package || '');
}
},
sendPhoneCall(phoneNumber, phoneAppOnly = false) {
Expand Down