expo-sharing 11.2.2 → 11.3.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.
- package/CHANGELOG.md +11 -3
- package/README.md +1 -1
- package/android/build.gradle +2 -2
- package/expo-module.config.json +3 -0
- package/ios/Exceptions.swift +25 -0
- package/ios/{EXSharing.podspec → ExpoSharing.podspec} +10 -3
- package/ios/SharingModule.swift +43 -0
- package/ios/SharingOptions.swift +7 -0
- package/package.json +2 -2
- package/ios/EXSharing/EXSharingModule.h +0 -8
- package/ios/EXSharing/EXSharingModule.m +0 -85
package/CHANGELOG.md
CHANGED
|
@@ -10,9 +10,17 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
## 11.
|
|
13
|
+
## 11.3.1 — 2023-04-14
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- On iOS, fixed an issue where file permissions were not checked correctly. ([#22112](https://github.com/expo/expo/pull/22112) by [@alanjhughes](https://github.com/alanjhughes))
|
|
18
|
+
|
|
19
|
+
## 11.3.0 — 2023-04-12
|
|
20
|
+
|
|
21
|
+
### 🎉 New features
|
|
22
|
+
|
|
23
|
+
- On iOS, switched from using `UIDocumentInteractionController` to `UIActivityViewController` which provides more features. ([#22012](https://github.com/expo/expo/pull/22012) by [@alanjhughes](https://github.com/alanjhughes))
|
|
16
24
|
|
|
17
25
|
## 11.2.1 — 2023-02-09
|
|
18
26
|
|
|
@@ -28,7 +36,7 @@ _This version does not introduce any user-facing changes._
|
|
|
28
36
|
|
|
29
37
|
### 🎉 New features
|
|
30
38
|
|
|
31
|
-
- Migrated
|
|
39
|
+
- Migrated module to Expo Modules API. ([#20112](https://github.com/expo/expo/pull/20112) and ([#20969](https://github.com/expo/expo/pull/20969) by [@alanhughes](https://github.com/alanjhughes))
|
|
32
40
|
|
|
33
41
|
## 11.0.1 — 2022-10-27
|
|
34
42
|
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Sharing standalone module
|
|
|
9
9
|
|
|
10
10
|
# Installation in managed Expo projects
|
|
11
11
|
|
|
12
|
-
For [managed](https://docs.expo.dev/
|
|
12
|
+
For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/sharing/).
|
|
13
13
|
|
|
14
14
|
# Installation in bare React Native projects
|
|
15
15
|
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '11.
|
|
6
|
+
version = '11.3.1'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -74,7 +74,7 @@ android {
|
|
|
74
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
75
75
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
76
76
|
versionCode 16
|
|
77
|
-
versionName '11.
|
|
77
|
+
versionName '11.3.1'
|
|
78
78
|
}
|
|
79
79
|
lintOptions {
|
|
80
80
|
abortOnError false
|
package/expo-module.config.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
|
|
3
|
+
internal class FilePermissionException: Exception {
|
|
4
|
+
override var reason: String {
|
|
5
|
+
"You don't have access to the provided file"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
internal class MissingCurrentViewControllerException: Exception {
|
|
10
|
+
override var reason: String {
|
|
11
|
+
"Cannot determine currently presented view controller"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
internal class UnsupportedTypeException: Exception {
|
|
16
|
+
override var reason: String {
|
|
17
|
+
"Could not share file since there were no apps registered for its type"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
internal class FilePermissionModuleException: Exception {
|
|
22
|
+
override var reason: String {
|
|
23
|
+
"File permission module not found"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -3,7 +3,7 @@ require 'json'
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
|
|
4
4
|
|
|
5
5
|
Pod::Spec.new do |s|
|
|
6
|
-
s.name = '
|
|
6
|
+
s.name = 'ExpoSharing'
|
|
7
7
|
s.version = package['version']
|
|
8
8
|
s.summary = package['description']
|
|
9
9
|
s.description = package['description']
|
|
@@ -11,15 +11,22 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.homepage = package['homepage']
|
|
13
13
|
s.platform = :ios, '13.0'
|
|
14
|
+
s.swift_version = '5.4'
|
|
14
15
|
s.source = { git: 'https://github.com/expo/expo.git' }
|
|
15
16
|
s.static_framework = true
|
|
16
17
|
|
|
17
18
|
s.dependency 'ExpoModulesCore'
|
|
18
19
|
|
|
20
|
+
# Swift/Objective-C compatibility
|
|
21
|
+
s.pod_target_xcconfig = {
|
|
22
|
+
'DEFINES_MODULE' => 'YES',
|
|
23
|
+
'SWIFT_COMPILATION_MODE' => 'wholemodule'
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
|
|
20
|
-
s.source_files = "
|
|
27
|
+
s.source_files = "**/*.h"
|
|
21
28
|
s.vendored_frameworks = "#{s.name}.xcframework"
|
|
22
29
|
else
|
|
23
|
-
s.source_files = "
|
|
30
|
+
s.source_files = "**/*.{h,m,swift}"
|
|
24
31
|
end
|
|
25
32
|
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
|
|
3
|
+
public final class SharingModule: Module {
|
|
4
|
+
|
|
5
|
+
public func definition() -> ModuleDefinition {
|
|
6
|
+
Name("ExpoSharing")
|
|
7
|
+
|
|
8
|
+
AsyncFunction("shareAsync") { (url: URL, options: SharingOptions, promise: Promise) in
|
|
9
|
+
guard let filePermissions: EXFilePermissionModuleInterface =
|
|
10
|
+
appContext?.legacyModule(implementing: EXFilePermissionModuleInterface.self)
|
|
11
|
+
else {
|
|
12
|
+
throw FilePermissionModuleException()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let grantedPermissions = filePermissions.getPathPermissions(url.relativePath)
|
|
16
|
+
guard grantedPermissions.rawValue >= EXFileSystemPermissionFlags.read.rawValue else {
|
|
17
|
+
throw FilePermissionException()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let activityController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
|
|
21
|
+
activityController.title = options.dialogTitle
|
|
22
|
+
|
|
23
|
+
activityController.completionWithItemsHandler = { type, completed, _, _ in
|
|
24
|
+
// user shared an item
|
|
25
|
+
if type != nil && completed {
|
|
26
|
+
promise.resolve(nil)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// dismissed without action
|
|
30
|
+
if type == nil && !completed {
|
|
31
|
+
promise.resolve(nil)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
guard let currentViewcontroller = appContext?.utilities?.currentViewController() else {
|
|
36
|
+
throw MissingCurrentViewControllerException()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
currentViewcontroller.present(activityController, animated: true)
|
|
40
|
+
}
|
|
41
|
+
.runOnQueue(.main)
|
|
42
|
+
}
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-sharing",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.1",
|
|
4
4
|
"description": "ExpoSharing standalone module",
|
|
5
5
|
"main": "build/Sharing.js",
|
|
6
6
|
"types": "build/Sharing.d.ts",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"expo": "*"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "5d628076915823cbe56e281ec17c3a34cc0c1fc6"
|
|
41
41
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Copyright © 2018 650 Industries. All rights reserved.
|
|
2
|
-
|
|
3
|
-
#import <ExpoModulesCore/EXExportedModule.h>
|
|
4
|
-
#import <ExpoModulesCore/EXModuleRegistryConsumer.h>
|
|
5
|
-
#import <UIKit/UIKit.h>
|
|
6
|
-
|
|
7
|
-
@interface EXSharingModule : EXExportedModule <EXModuleRegistryConsumer, UIDocumentInteractionControllerDelegate>
|
|
8
|
-
@end
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-present 650 Industries. All rights reserved.
|
|
2
|
-
|
|
3
|
-
#import <EXSharing/EXSharingModule.h>
|
|
4
|
-
#import <ExpoModulesCore/EXUtilitiesInterface.h>
|
|
5
|
-
#import <ExpoModulesCore/EXFileSystemInterface.h>
|
|
6
|
-
#import <ExpoModulesCore/EXFilePermissionModuleInterface.h>
|
|
7
|
-
|
|
8
|
-
@interface EXSharingModule ()
|
|
9
|
-
|
|
10
|
-
@property (nonatomic, weak) EXModuleRegistry *moduleRegistry;
|
|
11
|
-
@property (nonatomic, strong) UIDocumentInteractionController *documentInteractionController;
|
|
12
|
-
|
|
13
|
-
@property (nonatomic, strong) EXPromiseResolveBlock pendingResolver;
|
|
14
|
-
|
|
15
|
-
@end
|
|
16
|
-
|
|
17
|
-
@implementation EXSharingModule
|
|
18
|
-
|
|
19
|
-
EX_EXPORT_MODULE(ExpoSharing);
|
|
20
|
-
|
|
21
|
-
- (void)setModuleRegistry:(EXModuleRegistry *)moduleRegistry
|
|
22
|
-
{
|
|
23
|
-
_moduleRegistry = moduleRegistry;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
EX_EXPORT_METHOD_AS(shareAsync,
|
|
27
|
-
fileUrl:(NSString *)fileUrl
|
|
28
|
-
params:(NSDictionary *)params
|
|
29
|
-
resolve:(EXPromiseResolveBlock)resolve
|
|
30
|
-
reject:(EXPromiseRejectBlock)reject)
|
|
31
|
-
{
|
|
32
|
-
if (_documentInteractionController) {
|
|
33
|
-
NSString *errorMessage = @"Another item is being shared. Await the `shareAsync` request and then share the item again.";
|
|
34
|
-
reject(@"E_SHARING_MUL", errorMessage, EXErrorWithMessage(errorMessage));
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
NSURL *url = [NSURL URLWithString:fileUrl];
|
|
39
|
-
|
|
40
|
-
id<EXFilePermissionModuleInterface> filePermissionsModule = [_moduleRegistry getModuleImplementingProtocol:@protocol(EXFilePermissionModuleInterface)];
|
|
41
|
-
if (filePermissionsModule && !([filePermissionsModule getPathPermissions:url.path] & EXFileSystemPermissionRead)) {
|
|
42
|
-
NSString *errorMessage = @"You don't have access to provided file.";
|
|
43
|
-
reject(@"E_SHARING_PERM", errorMessage, EXErrorWithMessage(errorMessage));
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
_documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:url];
|
|
48
|
-
_documentInteractionController.delegate = self;
|
|
49
|
-
_documentInteractionController.UTI = params[@"UTI"];
|
|
50
|
-
|
|
51
|
-
EX_WEAKIFY(self);
|
|
52
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
53
|
-
EX_ENSURE_STRONGIFY(self);
|
|
54
|
-
UIViewController *viewController = [[self.moduleRegistry getModuleImplementingProtocol:@protocol(EXUtilitiesInterface)] currentViewController];
|
|
55
|
-
UIView *rootView = [viewController view];
|
|
56
|
-
if ([self.documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:rootView animated:YES]) {
|
|
57
|
-
self.pendingResolver = resolve;
|
|
58
|
-
} else {
|
|
59
|
-
reject(@"ERR_SHARING_UNSUPPORTED_TYPE", @"Could not share file since there were no apps registered for its type", nil);
|
|
60
|
-
self.documentInteractionController = nil;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller
|
|
66
|
-
{
|
|
67
|
-
_pendingResolver(nil);
|
|
68
|
-
_pendingResolver = nil;
|
|
69
|
-
|
|
70
|
-
// This delegate method is called whenever:
|
|
71
|
-
// a) the share sheet is canceled
|
|
72
|
-
// b) an app is chosen, it's dialog opened, and the share is confirmed/ sent
|
|
73
|
-
// c) an app is chosen, it's dialog opened, and that dialog is canceled
|
|
74
|
-
// In case c), the share sheet remains open, even though the promise was resolved
|
|
75
|
-
// Future attempts to share without closing the sheet will fail to attach the file, so we need to close it
|
|
76
|
-
// No other delegate methods fire only when the share sheet is dismissed, unfortunately
|
|
77
|
-
EX_WEAKIFY(self);
|
|
78
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
79
|
-
EX_ENSURE_STRONGIFY(self);
|
|
80
|
-
[self.documentInteractionController dismissMenuAnimated:true];
|
|
81
|
-
self.documentInteractionController = nil;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
@end
|