react-native-share 7.3.3 → 7.3.4

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.
@@ -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.3",
4
+ "version": "7.3.4",
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.8.4",
29
- "@babel/runtime": "^7.11.2",
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.63.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": "16.13.1",
48
- "react-native": "0.63.2",
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",