react-native-share 12.0.11 → 12.1.1

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.
@@ -2,5 +2,4 @@
2
2
  <paths xmlns:android="http://schemas.android.com/apk/res/android">
3
3
  <external-path name="rnshare1" path="Download/" />
4
4
  <cache-path name="rnshare2" path="/" />
5
- <root-path name="rnshare_sdcard" path="." />
6
5
  </paths>
package/ios/RNShare.mm CHANGED
@@ -18,6 +18,7 @@
18
18
  #import "GooglePlusShare.h"
19
19
  #import "EmailShare.h"
20
20
  #import "TelegramShare.h"
21
+ #import "TwitterShare.h"
21
22
  #import "ViberShare.h"
22
23
  #import "MessengerShare.h"
23
24
  #import "SmsShare.h"
@@ -153,10 +154,14 @@ RCT_EXPORT_METHOD(shareSingle:(NSDictionary *)options
153
154
  NSLog(@"TRY OPEN instagram-stories");
154
155
  InstagramStories *shareCtl = [[InstagramStories alloc] init];
155
156
  [shareCtl shareSingle:options reject: reject resolve: resolve];
156
- } else if([social isEqualToString:@"telegram"]) {
157
+ } else if([social isEqualToString:@"telegram"]) {
157
158
  NSLog(@"TRY OPEN telegram");
158
159
  TelegramShare *shareCtl = [[TelegramShare alloc] init];
159
160
  [shareCtl shareSingle:options reject: reject resolve: resolve];
161
+ } else if([social isEqualToString:@"twitter"]) {
162
+ NSLog(@"TRY OPEN twitter");
163
+ TwitterShare *shareCtl = [[TwitterShare alloc] init];
164
+ [shareCtl shareSingle:options reject: reject resolve: resolve];
160
165
  } else if([social isEqualToString:@"email"]) {
161
166
  NSLog(@"TRY OPEN email");
162
167
  [shareCtl shareSingle:options reject: reject resolve: resolve];
@@ -0,0 +1,23 @@
1
+ //
2
+ // TwitterShare.h
3
+ // RNShare
4
+ //
5
+ // Created by Akinn Rosa on 06-06-25.
6
+ //
7
+
8
+ #import <UIKit/UIKit.h>
9
+ // import RCTConvert
10
+ #import <React/RCTConvert.h>
11
+ // import RCTBridge
12
+ #import <React/RCTBridge.h>
13
+ // import RCTUIManager
14
+ #import <React/RCTUIManager.h>
15
+ // import RCTLog
16
+ #import <React/RCTLog.h>
17
+ // import RCTUtils
18
+ #import <React/RCTUtils.h>
19
+ @interface TwitterShare : NSObject <RCTBridgeModule>
20
+
21
+ - (void) shareSingle:(NSDictionary *)options reject:(RCTPromiseRejectBlock)reject resolve:(RCTPromiseResolveBlock)resolve;
22
+
23
+ @end
@@ -0,0 +1,48 @@
1
+ //
2
+ // TwitterShare.m
3
+ // RNShare
4
+ //
5
+ // Created by Akinn Rosa on 06-06-25.
6
+ //
7
+
8
+ #import "TwitterShare.h"
9
+ #import <AVFoundation/AVFoundation.h>
10
+ @import Photos;
11
+
12
+ @implementation TwitterShare
13
+ RCT_EXPORT_MODULE();
14
+
15
+ - (void)shareSingle:(NSDictionary *)options
16
+ reject:(RCTPromiseRejectBlock)reject
17
+ resolve:(RCTPromiseResolveBlock)resolve {
18
+
19
+ NSString *text = [RCTConvert NSString:options[@"message"]];
20
+ NSString *url = [RCTConvert NSString:options[@"url"]];
21
+
22
+ // URL encode text and url
23
+ NSString *encodedText = (NSString*)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
24
+ NULL, (CFStringRef)text, NULL, CFSTR("!*'();:@&=+$,/?%#[]"), kCFStringEncodingUTF8));
25
+
26
+ NSString *encodedUrl = url ? (NSString*)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
27
+ NULL, (CFStringRef)url, NULL, CFSTR("!*'();:@&=+$,/?%#[]"), kCFStringEncodingUTF8)) : nil;
28
+
29
+ // First try deep link to app
30
+ NSString *appUrlString = [NSString stringWithFormat:@"twitter://post?message=%@", encodedText];
31
+ NSURL *appUrl = [NSURL URLWithString:appUrlString];
32
+
33
+ if ([[UIApplication sharedApplication] canOpenURL:appUrl]) {
34
+ [[UIApplication sharedApplication] openURL:appUrl options:@{} completionHandler:^(BOOL success) {}];
35
+ resolve(@[@true, @"opened in twitter app"]);
36
+ } else {
37
+ // Fallback to web intent
38
+ NSString *webUrlString = url ?
39
+ [NSString stringWithFormat:@"https://twitter.com/intent/tweet?text=%@&url=%@", encodedText, encodedUrl] :
40
+ [NSString stringWithFormat:@"https://twitter.com/intent/tweet?text=%@", encodedText];
41
+
42
+ NSURL *webUrl = [NSURL URLWithString:webUrlString];
43
+ [[UIApplication sharedApplication] openURL:webUrl options:@{} completionHandler:^(BOOL success) {}];
44
+ resolve(@[@true, @"opened in browser"]);
45
+ }
46
+ }
47
+
48
+ @end
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": "12.0.11",
4
+ "version": "12.1.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/react-native-community/react-native-share.git"