react-native-share 7.3.2 → 7.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/cl/json/RNShareModule.java +2 -1
- package/android/src/main/java/cl/json/social/InstagramStoriesShare.java +2 -2
- package/android/src/main/java/cl/json/social/WhatsAppBusinessShare.java +24 -0
- package/android/src/main/java/cl/json/social/WhatsAppShare.java +24 -0
- package/package.json +7 -7
|
@@ -14,6 +14,7 @@ import com.facebook.react.bridge.ReadableMap;
|
|
|
14
14
|
import com.facebook.react.bridge.Callback;
|
|
15
15
|
|
|
16
16
|
import java.util.HashMap;
|
|
17
|
+
import java.util.Locale;
|
|
17
18
|
import java.util.Map;
|
|
18
19
|
|
|
19
20
|
import cl.json.social.EmailShare;
|
|
@@ -141,7 +142,7 @@ public class RNShareModule extends ReactContextBaseJavaModule implements Activit
|
|
|
141
142
|
public Map<String, Object> getConstants() {
|
|
142
143
|
Map<String, Object> constants = new HashMap<>();
|
|
143
144
|
for (SHARES val : SHARES.values()) {
|
|
144
|
-
constants.put(val.toString().toUpperCase(), val.toString());
|
|
145
|
+
constants.put(val.toString().toUpperCase(Locale.ROOT), val.toString());
|
|
145
146
|
}
|
|
146
147
|
return constants;
|
|
147
148
|
}
|
|
@@ -93,14 +93,14 @@ public class InstagramStoriesShare extends SingleShareIntent {
|
|
|
93
93
|
backgroundFileName = options.getString("backgroundVideo");
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
ShareFile backgroundAsset = new ShareFile(backgroundFileName, "background", useInternalStorage, this.reactContext);
|
|
96
|
+
ShareFile backgroundAsset = new ShareFile(backgroundFileName, "image/jpeg", "background", useInternalStorage, this.reactContext);
|
|
97
97
|
|
|
98
98
|
this.intent.setDataAndType(backgroundAsset.getURI(), backgroundAsset.getType());
|
|
99
99
|
this.intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
if (this.hasValidKey("stickerImage", options)) {
|
|
103
|
-
ShareFile stickerAsset = new ShareFile(options.getString("stickerImage"), "sticker", useInternalStorage, this.reactContext);
|
|
103
|
+
ShareFile stickerAsset = new ShareFile(options.getString("stickerImage"), "image/png", "sticker", useInternalStorage, this.reactContext);
|
|
104
104
|
|
|
105
105
|
if (!hasBackgroundAsset) {
|
|
106
106
|
this.intent.setType("image/*");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package cl.json.social;
|
|
2
2
|
|
|
3
3
|
import android.content.ActivityNotFoundException;
|
|
4
|
+
import android.content.ComponentName;
|
|
4
5
|
|
|
5
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
7
|
import com.facebook.react.bridge.ReadableMap;
|
|
@@ -12,6 +13,11 @@ public class WhatsAppBusinessShare extends SingleShareIntent {
|
|
|
12
13
|
|
|
13
14
|
private static final String PACKAGE = "com.whatsapp.w4b";
|
|
14
15
|
private static final String PLAY_STORE_LINK = "market://details?id=com.whatsapp.w4b";
|
|
16
|
+
|
|
17
|
+
private static final String START_CONVERSATION_CLASS = "com.whatsapp.Conversation";
|
|
18
|
+
private static final String SHARE_TO_CONVERSATION_CLASS = "com.whatsapp.ContactPicker";
|
|
19
|
+
|
|
20
|
+
private static final int START_ACTIVITY_TIME_GAP_MS = 300;
|
|
15
21
|
|
|
16
22
|
public WhatsAppBusinessShare(ReactApplicationContext reactContext) {
|
|
17
23
|
super(reactContext);
|
|
@@ -19,6 +25,24 @@ public class WhatsAppBusinessShare extends SingleShareIntent {
|
|
|
19
25
|
@Override
|
|
20
26
|
public void open(ReadableMap options) throws ActivityNotFoundException {
|
|
21
27
|
super.open(options);
|
|
28
|
+
|
|
29
|
+
if (options.hasKey("whatsAppNumber")) {
|
|
30
|
+
// create an empty conversation in case it's not on contacts
|
|
31
|
+
this.getIntent().setComponent(new ComponentName(PACKAGE, START_CONVERSATION_CLASS));
|
|
32
|
+
this.openIntentChooser();
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
// leave room for the conversation to be created
|
|
36
|
+
try {
|
|
37
|
+
Thread.sleep(START_ACTIVITY_TIME_GAP_MS);
|
|
38
|
+
} catch (InterruptedException ex) {
|
|
39
|
+
ex.printStackTrace();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// share to conversation
|
|
43
|
+
this.getIntent().setComponent(new ComponentName(PACKAGE, SHARE_TO_CONVERSATION_CLASS));
|
|
44
|
+
}
|
|
45
|
+
|
|
22
46
|
// extra params here
|
|
23
47
|
this.openIntentChooser();
|
|
24
48
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package cl.json.social;
|
|
2
2
|
|
|
3
3
|
import android.content.ActivityNotFoundException;
|
|
4
|
+
import android.content.ComponentName;
|
|
4
5
|
|
|
5
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
7
|
import com.facebook.react.bridge.ReadableMap;
|
|
@@ -12,6 +13,11 @@ public class WhatsAppShare extends SingleShareIntent {
|
|
|
12
13
|
|
|
13
14
|
private static final String PACKAGE = "com.whatsapp";
|
|
14
15
|
private static final String PLAY_STORE_LINK = "market://details?id=com.whatsapp";
|
|
16
|
+
|
|
17
|
+
private static final String START_CONVERSATION_CLASS = "com.whatsapp.Conversation";
|
|
18
|
+
private static final String SHARE_TO_CONVERSATION_CLASS = "com.whatsapp.ContactPicker";
|
|
19
|
+
|
|
20
|
+
private static final int START_ACTIVITY_TIME_GAP_MS = 300;
|
|
15
21
|
|
|
16
22
|
public WhatsAppShare(ReactApplicationContext reactContext) {
|
|
17
23
|
super(reactContext);
|
|
@@ -19,6 +25,24 @@ public class WhatsAppShare extends SingleShareIntent {
|
|
|
19
25
|
@Override
|
|
20
26
|
public void open(ReadableMap options) throws ActivityNotFoundException {
|
|
21
27
|
super.open(options);
|
|
28
|
+
|
|
29
|
+
if (options.hasKey("whatsAppNumber")) {
|
|
30
|
+
// create an empty conversation in case it's not on contacts
|
|
31
|
+
this.getIntent().setComponent(new ComponentName(PACKAGE, START_CONVERSATION_CLASS));
|
|
32
|
+
this.openIntentChooser();
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
// leave room for the conversation to be created
|
|
36
|
+
try {
|
|
37
|
+
Thread.sleep(START_ACTIVITY_TIME_GAP_MS);
|
|
38
|
+
} catch (InterruptedException ex) {
|
|
39
|
+
ex.printStackTrace();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// share to conversation
|
|
43
|
+
this.getIntent().setComponent(new ComponentName(PACKAGE, SHARE_TO_CONVERSATION_CLASS));
|
|
44
|
+
}
|
|
45
|
+
|
|
22
46
|
// extra params here
|
|
23
47
|
this.openIntentChooser();
|
|
24
48
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-share",
|
|
3
3
|
"description": "Social share, sending simple data to other apps.",
|
|
4
|
-
"version": "7.3.
|
|
4
|
+
"version": "7.3.6",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/react-native-community/react-native-share.git"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"RNShare.podspec"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "^7.
|
|
29
|
-
"@babel/runtime": "^7.
|
|
28
|
+
"@babel/core": "^7.12.9",
|
|
29
|
+
"@babel/runtime": "^7.12.5",
|
|
30
30
|
"@commitlint/cli": "11.0.0",
|
|
31
31
|
"@commitlint/config-conventional": "11.0.0",
|
|
32
32
|
"@react-native-community/eslint-config": "^3.0.0",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"eslint-config-satya164": "3.1.10",
|
|
42
42
|
"husky": "4.3.0",
|
|
43
43
|
"lint-staged": "10.3.0",
|
|
44
|
-
"metro-react-native-babel-preset": "^0.
|
|
44
|
+
"metro-react-native-babel-preset": "^0.66.2",
|
|
45
45
|
"pre-commit": "1.2.2",
|
|
46
46
|
"prettier": "^2.2.1",
|
|
47
|
-
"react": "
|
|
48
|
-
"react-native": "0.
|
|
47
|
+
"react": "17.0.2",
|
|
48
|
+
"react-native": "0.66.4",
|
|
49
49
|
"react-native-builder-bob": "^0.18.1",
|
|
50
50
|
"semantic-release": "^17.1.1",
|
|
51
51
|
"typescript": "4.2.4"
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"scripts": {
|
|
76
76
|
"start": "react-native start",
|
|
77
77
|
"start:android": "react-native run-android",
|
|
78
|
-
"start:ios": "react-native run-ios",
|
|
78
|
+
"start:ios": "react-native run-ios --project-path example/ios",
|
|
79
79
|
"lint": "eslint \"src/**/*.{js,ts,tsx}\" --max-warnings=0",
|
|
80
80
|
"typescript": "tsc --noEmit",
|
|
81
81
|
"validate": "yarn lint && yarn typescript",
|