react-native-share 12.2.5 → 12.2.6
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/ios/InstagramShare.m +16 -15
- package/ios/WhatsAppShare.m +54 -1
- package/package.json +1 -1
package/ios/InstagramShare.m
CHANGED
|
@@ -127,25 +127,26 @@
|
|
|
127
127
|
_mChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:image];
|
|
128
128
|
placeholder = _mChangeRequest.placeholderForCreatedAsset;
|
|
129
129
|
} completionHandler:^(BOOL success, NSError *error) {
|
|
130
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
131
|
+
if (success) {
|
|
132
|
+
NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?LocalIdentifier=\%@", [placeholder localIdentifier]]];
|
|
130
133
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (resolve != NULL) {
|
|
139
|
-
resolve(@[@true, @""]);
|
|
134
|
+
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
|
|
135
|
+
if (@available(iOS 10.0, *)) {
|
|
136
|
+
[[UIApplication sharedApplication] openURL:instagramURL options:@{} completionHandler:NULL];
|
|
137
|
+
}
|
|
138
|
+
if (resolve != NULL) {
|
|
139
|
+
resolve(@[@true, @""]);
|
|
140
|
+
}
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
else {
|
|
144
|
+
//Error while writing
|
|
145
|
+
if (reject != NULL) {
|
|
146
|
+
reject(@"com.rnshare",@"error",error);
|
|
147
|
+
}
|
|
147
148
|
}
|
|
148
|
-
}
|
|
149
|
+
});
|
|
149
150
|
}];
|
|
150
151
|
}
|
|
151
152
|
|
package/ios/WhatsAppShare.m
CHANGED
|
@@ -197,12 +197,65 @@ resolve:(RCTPromiseResolveBlock)resolve {
|
|
|
197
197
|
return FALSE;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
-(UIView *)presentationView {
|
|
201
|
+
UIWindow *window = nil;
|
|
202
|
+
|
|
203
|
+
if (@available(iOS 13.0, *)) {
|
|
204
|
+
for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) {
|
|
205
|
+
if (![scene isKindOfClass:[UIWindowScene class]]) {
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
UIWindowScene *windowScene = (UIWindowScene *)scene;
|
|
209
|
+
if (windowScene.activationState != UISceneActivationStateForegroundActive) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
for (UIWindow *candidate in windowScene.windows) {
|
|
213
|
+
if (candidate.isKeyWindow) {
|
|
214
|
+
window = candidate;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (window != nil) {
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (window == nil) {
|
|
225
|
+
for (UIWindow *candidate in UIApplication.sharedApplication.windows) {
|
|
226
|
+
if (candidate.isKeyWindow) {
|
|
227
|
+
window = candidate;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (window == nil) {
|
|
234
|
+
window = UIApplication.sharedApplication.windows.firstObject;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
UIViewController *viewController = window.rootViewController;
|
|
238
|
+
if (viewController == nil) {
|
|
239
|
+
return nil;
|
|
240
|
+
}
|
|
241
|
+
while (viewController.presentedViewController != nil) {
|
|
242
|
+
viewController = viewController.presentedViewController;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return viewController.view;
|
|
246
|
+
}
|
|
247
|
+
|
|
200
248
|
-(void)shareMedia:(NSString *)stringURL documentUTI:(NSString *)documentUTI {
|
|
201
249
|
NSURL *filePath = [NSURL fileURLWithPath:stringURL];
|
|
202
250
|
documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:filePath];
|
|
203
251
|
documentInteractionController.UTI = documentUTI;
|
|
204
252
|
documentInteractionController.delegate = self;
|
|
205
|
-
|
|
253
|
+
UIView *view = [self presentationView];
|
|
254
|
+
if (view == nil) {
|
|
255
|
+
NSLog(@"Unable to find a presentation view for WhatsApp share");
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
[documentInteractionController presentOpenInMenuFromRect:view.bounds inView:view animated:YES];
|
|
206
259
|
}
|
|
207
260
|
|
|
208
261
|
@end
|
package/package.json
CHANGED