react-native-share 12.2.2 → 12.2.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.
- package/README.md +2 -1
- package/ios/WhatsAppShare.m +23 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
# react-native-share
|
|
1
|
+
# react-native-share 
|
|
2
|
+
[](http://badge.fury.io/js/react-native-share) [](https://github.com/semantic-release/semantic-release)
|
|
2
3
|
|
|
3
4
|
React Native Share, is a simple tool for sharing messages and files with other apps.
|
|
4
5
|
|
package/ios/WhatsAppShare.m
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
typedef NS_ENUM(NSInteger, MessageType) {
|
|
12
12
|
MessageTypeImage,
|
|
13
13
|
MessageTypeVideo,
|
|
14
|
-
MessageTypeText
|
|
14
|
+
MessageTypeText,
|
|
15
|
+
MessageTypeAudio
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
@implementation WhatsAppShare
|
|
@@ -44,6 +45,10 @@ resolve:(RCTPromiseResolveBlock)resolve {
|
|
|
44
45
|
case MessageTypeVideo:
|
|
45
46
|
[self tryToSendVideo: options resolve:resolve reject:reject];
|
|
46
47
|
break;
|
|
48
|
+
|
|
49
|
+
case MessageTypeAudio:
|
|
50
|
+
[self tryToSendAudio:options resolve:resolve reject:reject];
|
|
51
|
+
break;
|
|
47
52
|
|
|
48
53
|
default:
|
|
49
54
|
[self tryToSendText: options resolve:resolve reject:reject];
|
|
@@ -67,8 +72,8 @@ resolve:(RCTPromiseResolveBlock)resolve {
|
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
image = [UIImage imageWithData: data];
|
|
70
|
-
NSString *
|
|
71
|
-
NSString *
|
|
75
|
+
NSString *tempPath = NSTemporaryDirectory();
|
|
76
|
+
NSString *filePath = [tempPath stringByAppendingPathComponent:@"image.jpg"];
|
|
72
77
|
|
|
73
78
|
[UIImageJPEGRepresentation(image, 1.0) writeToFile:filePath atomically:YES];
|
|
74
79
|
|
|
@@ -93,6 +98,16 @@ resolve:(RCTPromiseResolveBlock)resolve {
|
|
|
93
98
|
resolve(@[@true, @""]);
|
|
94
99
|
}
|
|
95
100
|
|
|
101
|
+
- (void)tryToSendAudio:(NSDictionary *)options
|
|
102
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
103
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
104
|
+
|
|
105
|
+
NSLog(@"Sending whatsapp audio");
|
|
106
|
+
[self shareMedia:options[@"url"] documentUTI:@"net.whatsapp.audio"];
|
|
107
|
+
NSLog(@"Done whatsapp audio");
|
|
108
|
+
resolve(@[ @true, @"" ]);
|
|
109
|
+
}
|
|
110
|
+
|
|
96
111
|
-(void)tryToSendText:(NSDictionary *)options
|
|
97
112
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
98
113
|
reject:(RCTPromiseRejectBlock)reject {
|
|
@@ -123,6 +138,11 @@ resolve:(RCTPromiseResolveBlock)resolve {
|
|
|
123
138
|
if([self isMediaType:url mediaExtensions:videoExtensions]){
|
|
124
139
|
return MessageTypeVideo;
|
|
125
140
|
}
|
|
141
|
+
|
|
142
|
+
NSArray *audioExtensions = @[@".mp3", @".aac", @".ogg", @".wav", @".m4a"];
|
|
143
|
+
if ([self isMediaType:url mediaExtensions:audioExtensions]) {
|
|
144
|
+
return MessageTypeAudio;
|
|
145
|
+
}
|
|
126
146
|
|
|
127
147
|
return MessageTypeText;
|
|
128
148
|
}
|
package/package.json
CHANGED