react-native-share 12.0.6 → 12.0.7

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.
@@ -19,17 +19,17 @@ RCT_EXPORT_MODULE();
19
19
  // Putting dictionary of options inside an array
20
20
  NSArray *pasteboardItems = @[items];
21
21
  NSDictionary *pasteboardOptions = @{UIPasteboardOptionExpirationDate : [[NSDate date] dateByAddingTimeInterval:60 * 5]};
22
-
22
+
23
23
  [[UIPasteboard generalPasteboard] setItems:pasteboardItems options:pasteboardOptions];
24
24
  [[UIApplication sharedApplication] openURL:urlScheme options:@{} completionHandler:nil];
25
-
25
+
26
26
  resolve(@[@true, @""]);
27
27
  }
28
28
 
29
29
  - (void)shareSingle:(NSDictionary *)options
30
30
  reject:(RCTPromiseRejectBlock)reject
31
31
  resolve:(RCTPromiseResolveBlock)resolve {
32
-
32
+
33
33
  NSURL *urlScheme = [NSURL URLWithString:[NSString stringWithFormat:@"instagram-stories://share?source_application=%@", options[@"appId"]]];
34
34
  if (![[UIApplication sharedApplication] canOpenURL:urlScheme]) {
35
35
  NSError* error = [self fallbackInstagram];
@@ -85,50 +85,63 @@ RCT_EXPORT_MODULE();
85
85
 
86
86
  if(![options[@"backgroundVideo"] isEqual:[NSNull null]] && options[@"backgroundVideo"] != nil) {
87
87
  NSURL *backgroundVideoURL = [RCTConvert NSURL:options[@"backgroundVideo"]];
88
- NSString *urlString = backgroundVideoURL.absoluteString;
89
- NSURLComponents *components = [[NSURLComponents alloc] initWithString:urlString];
90
- NSString *assetId = nil;
91
-
92
- // Get asset ID from URL
93
- for (NSURLQueryItem *item in components.queryItems) {
94
- if ([item.name isEqualToString:@"id"]) {
95
- assetId = item.value;
96
- break;
97
- }
98
- }
99
88
 
100
- if (assetId) {
101
- // Fetch the asset
102
- PHFetchResult *fetchResult = [PHAsset fetchAssetsWithLocalIdentifiers:@[assetId] options:nil];
103
- PHAsset *asset = fetchResult.firstObject;
104
-
105
- if (asset) {
106
- PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
107
- options.networkAccessAllowed = YES;
108
- options.deliveryMode = PHVideoRequestOptionsDeliveryModeHighQualityFormat;
109
-
110
- [[PHImageManager defaultManager] requestAVAssetForVideo:asset
111
- options:options
112
- resultHandler:^(AVAsset * _Nullable avAsset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
113
- if ([avAsset isKindOfClass:[AVURLAsset class]]) {
114
- AVURLAsset *urlAsset = (AVURLAsset *)avAsset;
115
- NSData *video = [NSData dataWithContentsOfURL:urlAsset.URL];
116
-
117
- dispatch_async(dispatch_get_main_queue(), ^{
118
- if (video) {
119
- [items setObject:video forKey:@"com.instagram.sharedSticker.backgroundVideo"];
120
- [self openInstagramWithItems:items urlScheme:urlScheme resolve:resolve];
121
- } else {
122
- NSLog(@"Failed to convert video asset to NSData");
123
- [self openInstagramWithItems:items urlScheme:urlScheme resolve:resolve];
124
- }
125
- });
126
- }
127
- }];
128
- } else {
129
- NSLog(@"Could not find asset with ID: %@", assetId);
130
- [self openInstagramWithItems:items urlScheme:urlScheme resolve:resolve];
131
- }
89
+ if ([backgroundVideoURL.scheme isEqualToString:@"file"]) {
90
+ // Handle local file
91
+ NSData *videoData = [NSData dataWithContentsOfURL:backgroundVideoURL];
92
+ if (videoData) {
93
+ [items setObject:videoData forKey:@"com.instagram.sharedSticker.backgroundVideo"];
94
+ [self openInstagramWithItems:items urlScheme:urlScheme resolve:resolve];
95
+ } else {
96
+ NSLog(@"Failed to read local video file");
97
+ [self openInstagramWithItems:items urlScheme:urlScheme resolve:resolve];
98
+ }
99
+ } else {
100
+ NSString *urlString = backgroundVideoURL.absoluteString;
101
+ NSURLComponents *components = [[NSURLComponents alloc] initWithString:urlString];
102
+ NSString *assetId = nil;
103
+
104
+ // Get asset ID from URL
105
+ for (NSURLQueryItem *item in components.queryItems) {
106
+ if ([item.name isEqualToString:@"id"]) {
107
+ assetId = item.value;
108
+ break;
109
+ }
110
+ }
111
+
112
+ if (assetId) {
113
+ // Fetch the asset
114
+ PHFetchResult *fetchResult = [PHAsset fetchAssetsWithLocalIdentifiers:@[assetId] options:nil];
115
+ PHAsset *asset = fetchResult.firstObject;
116
+
117
+ if (asset) {
118
+ PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init];
119
+ options.networkAccessAllowed = YES;
120
+ options.deliveryMode = PHVideoRequestOptionsDeliveryModeHighQualityFormat;
121
+
122
+ [[PHImageManager defaultManager] requestAVAssetForVideo:asset
123
+ options:options
124
+ resultHandler:^(AVAsset * _Nullable avAsset, AVAudioMix * _Nullable audioMix, NSDictionary * _Nullable info) {
125
+ if ([avAsset isKindOfClass:[AVURLAsset class]]) {
126
+ AVURLAsset *urlAsset = (AVURLAsset *)avAsset;
127
+ NSData *video = [NSData dataWithContentsOfURL:urlAsset.URL];
128
+
129
+ dispatch_async(dispatch_get_main_queue(), ^{
130
+ if (video) {
131
+ [items setObject:video forKey:@"com.instagram.sharedSticker.backgroundVideo"];
132
+ [self openInstagramWithItems:items urlScheme:urlScheme resolve:resolve];
133
+ } else {
134
+ NSLog(@"Failed to convert video asset to NSData");
135
+ [self openInstagramWithItems:items urlScheme:urlScheme resolve:resolve];
136
+ }
137
+ });
138
+ }
139
+ }];
140
+ } else {
141
+ NSLog(@"Could not find asset with ID: %@", assetId);
142
+ [self openInstagramWithItems:items urlScheme:urlScheme resolve:resolve];
143
+ }
144
+ }
132
145
  }
133
146
  } else {
134
147
  [self openInstagramWithItems:items urlScheme:urlScheme resolve:resolve];
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.6",
4
+ "version": "12.0.7",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/react-native-community/react-native-share.git"
@@ -62,7 +62,9 @@
62
62
  "react-native-windows": "^0.72.19",
63
63
  "react-test-renderer": "^18.2.0",
64
64
  "semantic-release": "^22.0.7",
65
- "typescript": "^5.2.2"
65
+ "typescript": "^5.2.2",
66
+ "patch-package": "^8.0.0",
67
+ "postinstall-postinstall": "^2.1.0"
66
68
  },
67
69
  "resolutions": {
68
70
  "eslint-plugin-prettier": "5.0.1",
@@ -92,6 +94,7 @@
92
94
  },
93
95
  "readmeFilename": "README.md",
94
96
  "scripts": {
97
+ "postinstall": "patch-package",
95
98
  "start": "react-native start",
96
99
  "start:android": "react-native run-android",
97
100
  "start:ios": "react-native run-ios",
@@ -154,5 +157,6 @@
154
157
  },
155
158
  "engines": {
156
159
  "node": ">=16"
157
- }
160
+ },
161
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
158
162
  }