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 CHANGED
@@ -1,4 +1,5 @@
1
- # react-native-share [![react-native-share](https://circleci.com/gh/react-native-share/react-native-share.svg?style=svg)](https://app.circleci.com/pipelines/github/react-native-share/react-native-share) [![npm version](https://badge.fury.io/js/react-native-share.svg)](http://badge.fury.io/js/react-native-share) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
1
+ # react-native-share ![example workflow](https://github.com/react-native-share/react-native-share/actions/workflows/release.yml/badge.svg)
2
+ [![npm version](https://badge.fury.io/js/react-native-share.svg)](http://badge.fury.io/js/react-native-share) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](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
 
@@ -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 * documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
71
- NSString * filePath = [documentsPath stringByAppendingPathComponent:@"/whatsAppTmp.wai"];
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
@@ -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.2.2",
4
+ "version": "12.2.4",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/react-native-share/react-native-share.git"