@amazon-devices/expo-application 2.0.1758683737
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/.eslintrc.js +2 -0
- package/CHANGELOG.md +176 -0
- package/CMakeLists.txt +46 -0
- package/LICENSE +7 -0
- package/README.kepler.md +103 -0
- package/README.md +25 -0
- package/THIRD_PARTY_NOTICES.txt +24 -0
- package/android/build.gradle +115 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/application/ApplicationModule.kt +125 -0
- package/build/Application.d.ts +126 -0
- package/build/Application.d.ts.map +1 -0
- package/build/Application.js +184 -0
- package/build/Application.js.map +1 -0
- package/build/Application.types.d.ts +13 -0
- package/build/Application.types.d.ts.map +1 -0
- package/build/Application.types.js +11 -0
- package/build/Application.types.js.map +1 -0
- package/build/ExpoApplication.d.ts +3 -0
- package/build/ExpoApplication.d.ts.map +1 -0
- package/build/ExpoApplication.js +3 -0
- package/build/ExpoApplication.js.map +1 -0
- package/build/ExpoApplication.kepler.d.ts +11 -0
- package/build/ExpoApplication.kepler.d.ts.map +1 -0
- package/build/ExpoApplication.kepler.js +26 -0
- package/build/ExpoApplication.kepler.js.map +1 -0
- package/build/ExpoApplication.web.d.ts +11 -0
- package/build/ExpoApplication.web.d.ts.map +1 -0
- package/build/ExpoApplication.web.js +24 -0
- package/build/ExpoApplication.web.js.map +1 -0
- package/expo-module.config.json +10 -0
- package/ios/ApplicationExceptions.swift +19 -0
- package/ios/ApplicationModule.swift +48 -0
- package/ios/ApplicationModuleProvisioningProfile.swift +75 -0
- package/ios/ExpoApplication.podspec +32 -0
- package/kepler/ExpoApplication.cpp +78 -0
- package/kepler/ExpoApplication.h +44 -0
- package/kepler/KeplerInit.cpp +28 -0
- package/kepler/test/ExpoApplication.cpp +94 -0
- package/package.json +1 -0
- package/react-native.config.js +21 -0
- package/src/.gitkeep +0 -0
- package/src/Application.ts +196 -0
- package/src/Application.types.ts +14 -0
- package/src/ExpoApplication.kepler.ts +46 -0
- package/src/ExpoApplication.ts +3 -0
- package/src/ExpoApplication.web.ts +23 -0
- package/tsconfig.json +9 -0
- package/unimodule.json +4 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'ExpoApplication'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.description = package['description']
|
|
10
|
+
s.license = package['license']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.homepage = package['homepage']
|
|
13
|
+
s.platforms = { :ios => '13.0', :tvos => '13.0'}
|
|
14
|
+
s.swift_version = '5.4'
|
|
15
|
+
s.source = { git: 'https://github.com/expo/expo.git' }
|
|
16
|
+
s.static_framework = true
|
|
17
|
+
|
|
18
|
+
s.dependency 'ExpoModulesCore'
|
|
19
|
+
|
|
20
|
+
# Swift/Objective-C compatibility
|
|
21
|
+
s.pod_target_xcconfig = {
|
|
22
|
+
'DEFINES_MODULE' => 'YES',
|
|
23
|
+
'SWIFT_COMPILATION_MODE' => 'wholemodule'
|
|
24
|
+
}
|
|
25
|
+
|
|
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')
|
|
27
|
+
s.source_files = "#{s.name}/**/*.h"
|
|
28
|
+
s.vendored_frameworks = "#{s.name}.xcframework"
|
|
29
|
+
else
|
|
30
|
+
s.source_files = "**/*.{h,m,swift}"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* PROPRIETARY/CONFIDENTIAL
|
|
5
|
+
*
|
|
6
|
+
* Use is subject to license terms.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#include "ExpoApplication.h"
|
|
10
|
+
|
|
11
|
+
#include <KeplerScript/logger/KPLog.h>
|
|
12
|
+
|
|
13
|
+
using namespace orpheus::framework;
|
|
14
|
+
|
|
15
|
+
status::Status KeplerPackageManager::getSelfPackageInfo(packageManager::PackageInfo& packageInfo) const {
|
|
16
|
+
return packageManager::PackageManager::getInstance().getSelfPackageInfo(packageInfo);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
ExpoApplication::ExpoApplication(const IPackageManager& packageManager) : volta::react::KeplerTurboModule("ExpoApplication") {
|
|
20
|
+
volta::react::KPLog.debug("ExpoApplication constructor {}", name());
|
|
21
|
+
|
|
22
|
+
auto status = packageManager.getSelfPackageInfo(this->packageInfo);
|
|
23
|
+
if (!status.isOk()) {
|
|
24
|
+
throw "ExpoApplication failed to get package info with status: " + std::string{status.toString()};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
std::string ExpoApplication::applicationId() {
|
|
29
|
+
return packageInfo.id;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
std::string ExpoApplication::applicationName() {
|
|
33
|
+
return packageInfo.title;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
std::string ExpoApplication::nativeApplicationVersion() {
|
|
37
|
+
return packageInfo.version;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
std::string ExpoApplication::nativeBuildVersion() {
|
|
41
|
+
return packageInfo.version;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
volta::react::Promise ExpoApplication::getInstallationTimeAsync() {
|
|
45
|
+
return volta::react::Promise([this](std::shared_ptr<volta::react::Promise> promise) {
|
|
46
|
+
try {
|
|
47
|
+
// Returning this as a string due to the lack of support for time_t in callbacks
|
|
48
|
+
auto installationTimeStr = std::to_string(packageInfo.installTime);
|
|
49
|
+
promise->resolve(installationTimeStr);
|
|
50
|
+
} catch (std::exception& e) {
|
|
51
|
+
promise->reject(std::string{"getInstallationTimeAsync() error: " + std::string(e.what())});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
volta::react::Promise ExpoApplication::getLastUpdateTimeAsync() {
|
|
57
|
+
return volta::react::Promise([this](std::shared_ptr<volta::react::Promise> promise) {
|
|
58
|
+
try {
|
|
59
|
+
// Returning this as a string due to the lack of support for time_t in callbacks
|
|
60
|
+
auto lastUpdateTimeStr = std::to_string(packageInfo.updateTime);
|
|
61
|
+
promise->resolve(lastUpdateTimeStr);
|
|
62
|
+
} catch (std::exception& e) {
|
|
63
|
+
promise->reject(std::string{"getLastUpdateTimeAsync() error: " + std::string(e.what())});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void ExpoApplication::aggregateMethods(
|
|
69
|
+
volta::react::MethodAggregator<volta::react::KeplerTurboModule>& methodAggregator) const noexcept {
|
|
70
|
+
volta::react::KPLog.debug("methodAggregator");
|
|
71
|
+
|
|
72
|
+
methodAggregator.addMethod("applicationId", 0, &ExpoApplication::applicationId);
|
|
73
|
+
methodAggregator.addMethod("applicationName", 0, &ExpoApplication::applicationName);
|
|
74
|
+
methodAggregator.addMethod("nativeApplicationVersion", 0, &ExpoApplication::nativeApplicationVersion);
|
|
75
|
+
methodAggregator.addMethod("nativeBuildVersion", 0, &ExpoApplication::nativeBuildVersion);
|
|
76
|
+
methodAggregator.addMethod("getInstallationTimeAsync", 0, &ExpoApplication::getInstallationTimeAsync);
|
|
77
|
+
methodAggregator.addMethod("getLastUpdateTimeAsync", 0, &ExpoApplication::getLastUpdateTimeAsync);
|
|
78
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* PROPRIETARY/CONFIDENTIAL
|
|
5
|
+
*
|
|
6
|
+
* Use is subject to license terms.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#include <KeplerScript/modules/KeplerTurboModule.h>
|
|
10
|
+
#include <orpheus/framework/package-manager/PackageManager.h>
|
|
11
|
+
|
|
12
|
+
class IPackageManager {
|
|
13
|
+
public:
|
|
14
|
+
virtual ~IPackageManager() = default;
|
|
15
|
+
virtual orpheus::framework::status::Status getSelfPackageInfo(orpheus::framework::packageManager::PackageInfo& packageInfo) const = 0;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
class KEPLERSCRIPT_EXPORT KeplerPackageManager : public IPackageManager {
|
|
19
|
+
public:
|
|
20
|
+
orpheus::framework::status::Status getSelfPackageInfo(orpheus::framework::packageManager::PackageInfo& packageInfo) const override;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
class KEPLERSCRIPT_EXPORT ExpoApplication : public volta::react::KeplerTurboModule {
|
|
24
|
+
public:
|
|
25
|
+
ExpoApplication(const IPackageManager& pm = KeplerPackageManager());
|
|
26
|
+
|
|
27
|
+
#ifndef UNIT_TEST
|
|
28
|
+
protected:
|
|
29
|
+
#endif
|
|
30
|
+
std::string applicationId();
|
|
31
|
+
std::string applicationName();
|
|
32
|
+
std::string nativeApplicationVersion();
|
|
33
|
+
std::string nativeBuildVersion();
|
|
34
|
+
volta::react::Promise getInstallationTimeAsync();
|
|
35
|
+
volta::react::Promise getLastUpdateTimeAsync();
|
|
36
|
+
|
|
37
|
+
void aggregateMethods(
|
|
38
|
+
volta::react::MethodAggregator<volta::react::KeplerTurboModule>& methodAggregator) const noexcept override;
|
|
39
|
+
|
|
40
|
+
#ifndef UNIT_TEST
|
|
41
|
+
private:
|
|
42
|
+
#endif
|
|
43
|
+
orpheus::framework::packageManager::PackageInfo packageInfo;
|
|
44
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* PROPRIETARY/CONFIDENTIAL
|
|
5
|
+
*
|
|
6
|
+
* Use is subject to license terms.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#include <KeplerScript/logger/KPLog.h>
|
|
10
|
+
#include <KeplerScript/utils/autolink/KeplerAutoLinkInfo.h>
|
|
11
|
+
#include <keplerui-072/keplerscript-export.h>
|
|
12
|
+
|
|
13
|
+
#include "ExpoApplication.h"
|
|
14
|
+
#include "RegisterModule.h"
|
|
15
|
+
|
|
16
|
+
extern "C" {
|
|
17
|
+
KEPLERSCRIPT_EXPORT void keplerAutoLinkInitV1(const kepler::autolink::v1::KeplerAutoLinkInfo* autoLinkInfo) noexcept {
|
|
18
|
+
volta::react::KPLog.debug("keplerAutoLinkInitV1 for ExpoApplication");
|
|
19
|
+
|
|
20
|
+
REGISTER_MODULE(autoLinkInfo, ExpoApplication, "ExpoApplication");
|
|
21
|
+
|
|
22
|
+
volta::react::KPLog.debug("after registering module");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
int main() {
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
*
|
|
4
|
+
* PROPRIETARY/CONFIDENTIAL
|
|
5
|
+
*
|
|
6
|
+
* Use is subject to license terms.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#include <gmock/gmock-actions.h>
|
|
10
|
+
#include <gmock/gmock.h>
|
|
11
|
+
#include <gtest/gtest.h>
|
|
12
|
+
|
|
13
|
+
#include "catch.hpp"
|
|
14
|
+
#include "JSObjectsConversion.h"
|
|
15
|
+
|
|
16
|
+
#include "../ExpoApplication.h"
|
|
17
|
+
|
|
18
|
+
using namespace volta::react;
|
|
19
|
+
|
|
20
|
+
class MockPackageManager : public IPackageManager {
|
|
21
|
+
public:
|
|
22
|
+
orpheus::framework::status::Status getSelfPackageInfo(orpheus::framework::packageManager::PackageInfo &packageInfo) const override {
|
|
23
|
+
packageInfo.id = "testID";
|
|
24
|
+
packageInfo.title = "testTitle";
|
|
25
|
+
packageInfo.version = "testVersion";
|
|
26
|
+
packageInfo.installTime = static_cast<std::time_t>(999);
|
|
27
|
+
packageInfo.updateTime = static_cast<std::time_t>(111);
|
|
28
|
+
return orpheus::framework::status::Status{};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// std::shared_ptr<Promise> getPromiseCallback(std::string& result) {
|
|
33
|
+
// return std::make_shared<Promise>(
|
|
34
|
+
// Callback([&result](auto v) {
|
|
35
|
+
// result = std::get<std::string>(v[0]);
|
|
36
|
+
// }),
|
|
37
|
+
// Callback([&result](auto v) {
|
|
38
|
+
// NativeJSObject m = ExpoUtils::convertJsonContainerToNativeJSObject(std::get<utils::json::JsonContainer>(v[0]));
|
|
39
|
+
// result = std::get<std::string>(m["message"]);
|
|
40
|
+
// }));
|
|
41
|
+
// }
|
|
42
|
+
|
|
43
|
+
TEST_CASE("ExpoApplication") {
|
|
44
|
+
ExpoApplication testExpoApplication{MockPackageManager()};
|
|
45
|
+
|
|
46
|
+
SECTION("ExpoApplication::applicationId") {
|
|
47
|
+
auto result = testExpoApplication.applicationId();
|
|
48
|
+
REQUIRE(result == "testID");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
SECTION("ExpoApplication::applicationName") {
|
|
52
|
+
auto result = testExpoApplication.applicationName();
|
|
53
|
+
REQUIRE(result == "testTitle");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
SECTION("ExpoApplication::nativeApplicationVersion") {
|
|
57
|
+
auto result = testExpoApplication.nativeApplicationVersion();
|
|
58
|
+
REQUIRE(result == "testVersion");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
SECTION("ExpoApplication::nativeBuildVersion") {
|
|
62
|
+
auto result = testExpoApplication.nativeBuildVersion();
|
|
63
|
+
REQUIRE(result == "testVersion");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Unable to test due to lack of 'Promise' support
|
|
67
|
+
// SECTION("ExpoApplication::getInstallationTimeAsync") {
|
|
68
|
+
// std::string result;
|
|
69
|
+
// auto promise = testExpoApplication.getInstallationTimeAsync();
|
|
70
|
+
// auto action = getPromiseCallback(result);
|
|
71
|
+
// promise.promiseOperation_(action);
|
|
72
|
+
// REQUIRE(result == "999");
|
|
73
|
+
// }
|
|
74
|
+
|
|
75
|
+
// Unable to test due to lack of 'Promise' support
|
|
76
|
+
// SECTION("ExpoApplication::getLastUpdateTimeAsync") {
|
|
77
|
+
// std::string result;
|
|
78
|
+
// auto promise = testExpoApplication.getLastUpdateTimeAsync();
|
|
79
|
+
// auto action = getPromiseCallback(result);
|
|
80
|
+
// promise.promiseOperation_(action);
|
|
81
|
+
// REQUIRE(result == "111");
|
|
82
|
+
// }
|
|
83
|
+
|
|
84
|
+
SECTION("ExpoApplication::aggregateMethods") {
|
|
85
|
+
std::weak_ptr<facebook::react::Instance> instance;
|
|
86
|
+
REQUIRE(testExpoApplication.methodContainerMap_.size() == 0);
|
|
87
|
+
testExpoApplication.triggerMethodAggregation(*testExpoApplication.jsQueue_, instance);
|
|
88
|
+
std::vector<std::string> propNames = {"applicationId", "applicationName", "nativeApplicationVersion", "nativeBuildVersion", "getInstallationTimeAsync", "getLastUpdateTimeAsync"};
|
|
89
|
+
for (auto& propName : propNames) {
|
|
90
|
+
REQUIRE(testExpoApplication.methodContainerMap_.find(propName) != testExpoApplication.methodContainerMap_.end());
|
|
91
|
+
}
|
|
92
|
+
REQUIRE(testExpoApplication.methodContainerMap_.size() == 8); // "addListener" and "removeListeners" are added by default
|
|
93
|
+
}
|
|
94
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name": "@amazon-devices/expo-application", "version": "2.0.1758683737+5.6.0", "description": "A universal module that gets native application information such as its ID, app name, and build version at runtime", "main": "build/Application.js", "types": "build/Application.d.ts", "scripts": {"build": "expo-module build", "clean": "expo-module clean", "lint": "expo-module lint", "test": "expo-module test", "expo-module": "expo-module"}, "kepler": {"temporary-alias-for-package": {"name": "expo-application", "version": "5.6.0"}}, "keywords": ["react-native", "expo", "expo-application"], "repository": {"type": "git", "url": "https://github.com/expo/expo.git", "directory": "packages/expo-application"}, "bugs": {"url": "https://github.com/expo/expo/issues"}, "author": "650 Industries, Inc.", "license": "See license in LICENSE", "homepage": "https://docs.expo.dev/versions/latest/sdk/application/", "jest": {"preset": "expo-module-scripts"}, "dependencies": {"@amazon-devices/keplerscript-turbomodule-api": "^1.0.0"}, "devDependencies": {"expo-module-scripts": "^3.0.0"}, "peerDependencies": {"expo": "*"}}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
dependencies: {
|
|
3
|
+
'@amazon-devices/react-native-kepler': {
|
|
4
|
+
platforms: {
|
|
5
|
+
kepler: null, // do not use platform definition from @react-native-kepler
|
|
6
|
+
},
|
|
7
|
+
},
|
|
8
|
+
},
|
|
9
|
+
dependency: {
|
|
10
|
+
platforms: {
|
|
11
|
+
kepler: {
|
|
12
|
+
autolink: {
|
|
13
|
+
ExpoApplicationLib: {
|
|
14
|
+
provider: 'system',
|
|
15
|
+
turbomodules: ['ExpoApplication'],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
package/src/.gitkeep
ADDED
|
File without changes
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Platform, UnavailabilityError } from 'expo-modules-core';
|
|
2
|
+
|
|
3
|
+
import { ApplicationReleaseType, PushNotificationServiceEnvironment } from './Application.types';
|
|
4
|
+
import ExpoApplication from './ExpoApplication';
|
|
5
|
+
|
|
6
|
+
// @needsAudit
|
|
7
|
+
/**
|
|
8
|
+
* The human-readable version of the native application that may be displayed in the app store.
|
|
9
|
+
* This is the `Info.plist` value for `CFBundleShortVersionString` on iOS and the version name set
|
|
10
|
+
* by `version` in `app.json` on Android at the time the native app was built.
|
|
11
|
+
* On web, this value is `null`.
|
|
12
|
+
* @example `"2.11.0"`
|
|
13
|
+
*/
|
|
14
|
+
export const nativeApplicationVersion: string | null = ExpoApplication
|
|
15
|
+
? ExpoApplication.nativeApplicationVersion || null
|
|
16
|
+
: null;
|
|
17
|
+
|
|
18
|
+
// @needsAudit
|
|
19
|
+
/**
|
|
20
|
+
* The internal build version of the native application that the app store may use to distinguish
|
|
21
|
+
* between different binaries. This is the `Info.plist` value for `CFBundleVersion` on iOS (set with
|
|
22
|
+
* `ios.buildNumber` value in `app.json` in a standalone app) and the version code set by
|
|
23
|
+
* `android.versionCode` in `app.json` on Android at the time the native app was built. On web, this
|
|
24
|
+
* value is `null`. The return type on Android and iOS is `string`.
|
|
25
|
+
* @example iOS: `"2.11.0"`, Android: `"114"`
|
|
26
|
+
*/
|
|
27
|
+
export const nativeBuildVersion: string | null = ExpoApplication
|
|
28
|
+
? ExpoApplication.nativeBuildVersion || null
|
|
29
|
+
: null;
|
|
30
|
+
|
|
31
|
+
// @needsAudit
|
|
32
|
+
/**
|
|
33
|
+
* The human-readable name of the application that is displayed with the app's icon on the device's
|
|
34
|
+
* home screen or desktop. On Android and iOS, this value is a `string` unless the name could not be
|
|
35
|
+
* retrieved, in which case this value will be `null`. On web this value is `null`.
|
|
36
|
+
* @example `"Expo"`, `"Yelp"`, `"Instagram"`
|
|
37
|
+
*/
|
|
38
|
+
export const applicationName: string | null = ExpoApplication
|
|
39
|
+
? ExpoApplication.applicationName || null
|
|
40
|
+
: null;
|
|
41
|
+
|
|
42
|
+
// @needsAudit
|
|
43
|
+
/**
|
|
44
|
+
* The ID of the application. On Android, this is the application ID. On iOS, this is the bundle ID.
|
|
45
|
+
* On web, this is `null`.
|
|
46
|
+
* @example `"com.cocoacasts.scribbles"`, `"com.apple.Pages"`
|
|
47
|
+
*/
|
|
48
|
+
export const applicationId: string | null = ExpoApplication
|
|
49
|
+
? ExpoApplication.applicationId || null
|
|
50
|
+
: null;
|
|
51
|
+
|
|
52
|
+
// @needsAudit
|
|
53
|
+
/**
|
|
54
|
+
* Gets the value of [`Settings.Secure.ANDROID_ID`](https://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID).
|
|
55
|
+
* This is a hexadecimal `string` unique to each combination of app-signing key, user, and device.
|
|
56
|
+
* The value may change if a factory reset is performed on the device or if an APK signing key changes.
|
|
57
|
+
* For more information about how the platform handles `ANDROID_ID` in Android 8.0 (API level 26)
|
|
58
|
+
* and higher, see [Android 8.0 Behavior Changes](https://developer.android.com/about/versions/oreo/android-8.0-changes.html#privacy-all).
|
|
59
|
+
* On iOS and web, this function is unavailable.
|
|
60
|
+
* > In versions of the platform lower than Android 8.0 (API level 26), this value remains constant
|
|
61
|
+
* > for the lifetime of the user's device. See the [ANDROID_ID](https://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID)
|
|
62
|
+
* > official docs for more information.
|
|
63
|
+
* @example `"dd96dec43fb81c97"`
|
|
64
|
+
* @platform android
|
|
65
|
+
*/
|
|
66
|
+
export function getAndroidId(): string {
|
|
67
|
+
if (Platform.OS !== 'android') {
|
|
68
|
+
throw new UnavailabilityError('expo-application', 'androidId');
|
|
69
|
+
}
|
|
70
|
+
return ExpoApplication.androidId;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// @needsAudit
|
|
74
|
+
/**
|
|
75
|
+
* Gets the referrer URL of the installed app with the [`Install Referrer API`](https://developer.android.com/google/play/installreferrer)
|
|
76
|
+
* from the Google Play Store. In practice, the referrer URL may not be a complete, absolute URL.
|
|
77
|
+
* @return A `Promise` that fulfills with a `string` of the referrer URL of the installed app.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* await Application.getInstallReferrerAsync();
|
|
82
|
+
* // "utm_source=google-play&utm_medium=organic"
|
|
83
|
+
* ```
|
|
84
|
+
* @platform android
|
|
85
|
+
*/
|
|
86
|
+
export async function getInstallReferrerAsync(): Promise<string> {
|
|
87
|
+
if (!ExpoApplication.getInstallReferrerAsync) {
|
|
88
|
+
throw new UnavailabilityError('expo-application', 'getInstallReferrerAsync');
|
|
89
|
+
}
|
|
90
|
+
return await ExpoApplication.getInstallReferrerAsync();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// @needsAudit
|
|
94
|
+
/**
|
|
95
|
+
* Gets the iOS "identifier for vendor" ([IDFV](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor))
|
|
96
|
+
* value, a string ID that uniquely identifies a device to the app’s vendor. This method may
|
|
97
|
+
* sometimes return `nil`, in which case wait and call the method again later. This might happen
|
|
98
|
+
* when the device has been restarted before the user has unlocked the device.
|
|
99
|
+
*
|
|
100
|
+
* The OS will change the vendor identifier if all apps from the current app's vendor have been
|
|
101
|
+
* uninstalled.
|
|
102
|
+
*
|
|
103
|
+
* @return A `Promise` that fulfills with a `string` specifying the app's vendor ID. Apps from the
|
|
104
|
+
* same vendor will return the same ID. See Apple's documentation for more information about the
|
|
105
|
+
* vendor ID's semantics.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* await Application.getIosIdForVendorAsync();
|
|
110
|
+
* // "68753A44-4D6F-1226-9C60-0050E4C00067"
|
|
111
|
+
* ```
|
|
112
|
+
* @platform ios
|
|
113
|
+
*/
|
|
114
|
+
export async function getIosIdForVendorAsync(): Promise<string | null> {
|
|
115
|
+
if (!ExpoApplication.getIosIdForVendorAsync) {
|
|
116
|
+
throw new UnavailabilityError('expo-application', 'getIosIdForVendorAsync');
|
|
117
|
+
}
|
|
118
|
+
return await ExpoApplication.getIosIdForVendorAsync();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// @needsAudit
|
|
122
|
+
/**
|
|
123
|
+
* Gets the iOS application release type.
|
|
124
|
+
* @return Returns a promise which fulfills with an [`ApplicationReleaseType`](#applicationreleasetype).
|
|
125
|
+
* @platform ios
|
|
126
|
+
*/
|
|
127
|
+
export async function getIosApplicationReleaseTypeAsync(): Promise<ApplicationReleaseType> {
|
|
128
|
+
if (!ExpoApplication.getApplicationReleaseTypeAsync) {
|
|
129
|
+
throw new UnavailabilityError('expo-application', 'getApplicationReleaseTypeAsync');
|
|
130
|
+
}
|
|
131
|
+
return await ExpoApplication.getApplicationReleaseTypeAsync();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// @needsAudit
|
|
135
|
+
/**
|
|
136
|
+
* Gets the current [Apple Push Notification (APN)](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment?language=objc)
|
|
137
|
+
* service environment.
|
|
138
|
+
* @return Returns a promise fulfilled with the string, either `'development'` or `'production'`,
|
|
139
|
+
* based on the current APN environment, or `null` on the simulator as it does not support registering with APNs.
|
|
140
|
+
* @platform ios
|
|
141
|
+
*/
|
|
142
|
+
export async function getIosPushNotificationServiceEnvironmentAsync(): Promise<PushNotificationServiceEnvironment> {
|
|
143
|
+
if (!ExpoApplication.getPushNotificationServiceEnvironmentAsync) {
|
|
144
|
+
throw new UnavailabilityError('expo-application', 'getPushNotificationServiceEnvironmentAsync');
|
|
145
|
+
}
|
|
146
|
+
return await ExpoApplication.getPushNotificationServiceEnvironmentAsync();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// @needsAudit
|
|
150
|
+
/**
|
|
151
|
+
* Gets the time the app was installed onto the device, not counting subsequent updates. If the app
|
|
152
|
+
* is uninstalled and reinstalled, this method returns the time the app was reinstalled.
|
|
153
|
+
* - On iOS, this method uses the [`NSFileCreationDate`](https://developer.apple.com/documentation/foundation/nsfilecreationdate?language=objc)
|
|
154
|
+
* of the app's document root directory.
|
|
155
|
+
* - On Android, this method uses [`PackageInfo.firstInstallTime`](https://developer.android.com/reference/android/content/pm/PackageInfo.html#firstInstallTime).
|
|
156
|
+
* - On web, this method returns `null`.
|
|
157
|
+
*
|
|
158
|
+
* @return Returns a `Promise` that fulfills with a `Date` object that specifies the time the app
|
|
159
|
+
* was installed on the device.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* await Application.getInstallationTimeAsync();
|
|
164
|
+
* // 2019-07-18T18:08:26.121Z
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export async function getInstallationTimeAsync(): Promise<Date> {
|
|
168
|
+
if (!ExpoApplication.getInstallationTimeAsync) {
|
|
169
|
+
throw new UnavailabilityError('expo-application', 'getInstallationTimeAsync');
|
|
170
|
+
}
|
|
171
|
+
const installationTime = await ExpoApplication.getInstallationTimeAsync();
|
|
172
|
+
return new Date(installationTime);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// @needsAudit
|
|
176
|
+
/**
|
|
177
|
+
* Gets the last time the app was updated from the Google Play Store.
|
|
178
|
+
* @return Returns a `Promise` that fulfills with a `Date` object that specifies the last time
|
|
179
|
+
* the app was updated via the Google Play Store).
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* await Application.getLastUpdateTimeAsync();
|
|
184
|
+
* // 2019-07-18T21:20:16.887Z
|
|
185
|
+
* ```
|
|
186
|
+
* @platform android
|
|
187
|
+
*/
|
|
188
|
+
export async function getLastUpdateTimeAsync(): Promise<Date> {
|
|
189
|
+
if (!ExpoApplication.getLastUpdateTimeAsync) {
|
|
190
|
+
throw new UnavailabilityError('expo-application', 'getLastUpdateTimeAsync');
|
|
191
|
+
}
|
|
192
|
+
const lastUpdateTime = await ExpoApplication.getLastUpdateTimeAsync();
|
|
193
|
+
return new Date(lastUpdateTime);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { ApplicationReleaseType, PushNotificationServiceEnvironment };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @docsMissing
|
|
2
|
+
export enum ApplicationReleaseType {
|
|
3
|
+
UNKNOWN = 0,
|
|
4
|
+
SIMULATOR = 1,
|
|
5
|
+
ENTERPRISE = 2,
|
|
6
|
+
DEVELOPMENT = 3,
|
|
7
|
+
AD_HOC = 4,
|
|
8
|
+
APP_STORE = 5,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Maps to the [`aps-environment`](https://developer.apple.com/documentation/bundleresources/entitlements/aps-environment) key in the native target's registered entitlements.
|
|
13
|
+
*/
|
|
14
|
+
export type PushNotificationServiceEnvironment = 'development' | 'production' | null;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {KeplerTurboModule, TurboModuleRegistry} from '@amazon-devices/keplerscript-turbomodule-api';
|
|
2
|
+
|
|
3
|
+
interface Spec extends KeplerTurboModule {
|
|
4
|
+
applicationId: () => string;
|
|
5
|
+
applicationName: () => string;
|
|
6
|
+
nativeApplicationVersion: () => string;
|
|
7
|
+
nativeBuildVersion: () => string;
|
|
8
|
+
getInstallationTimeAsync: () => Promise<string>;
|
|
9
|
+
getLastUpdateTimeAsync: () => Promise<string>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const nativeModule = TurboModuleRegistry.getEnforcing<Spec>('ExpoApplication') as Spec;
|
|
13
|
+
|
|
14
|
+
interface KeplerExpoApplication {
|
|
15
|
+
applicationId: string;
|
|
16
|
+
applicationName: string;
|
|
17
|
+
nativeApplicationVersion: string;
|
|
18
|
+
nativeBuildVersion: string;
|
|
19
|
+
getInstallationTimeAsync: () => Promise<number>;
|
|
20
|
+
getLastUpdateTimeAsync: () => Promise<number>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const module: KeplerExpoApplication = {
|
|
24
|
+
get applicationId() {
|
|
25
|
+
return nativeModule.applicationId();
|
|
26
|
+
},
|
|
27
|
+
get applicationName() {
|
|
28
|
+
return nativeModule.applicationName();
|
|
29
|
+
},
|
|
30
|
+
get nativeApplicationVersion() {
|
|
31
|
+
return nativeModule.nativeApplicationVersion();
|
|
32
|
+
},
|
|
33
|
+
get nativeBuildVersion() {
|
|
34
|
+
return nativeModule.nativeBuildVersion();
|
|
35
|
+
},
|
|
36
|
+
async getInstallationTimeAsync(): Promise<number> {
|
|
37
|
+
const installationTime = await nativeModule.getInstallationTimeAsync();
|
|
38
|
+
return Number.parseInt(installationTime) * 1000;
|
|
39
|
+
},
|
|
40
|
+
async getLastUpdateTimeAsync(): Promise<number> {
|
|
41
|
+
const lastUpdateTime = await nativeModule.getLastUpdateTimeAsync();
|
|
42
|
+
return Number.parseInt(lastUpdateTime) * 1000;
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default module;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
get name(): string {
|
|
3
|
+
return 'ExpoApplication';
|
|
4
|
+
},
|
|
5
|
+
get applicationName(): null {
|
|
6
|
+
return null;
|
|
7
|
+
},
|
|
8
|
+
get bundleId(): null {
|
|
9
|
+
return null;
|
|
10
|
+
},
|
|
11
|
+
get nativeApplicationVersion(): null {
|
|
12
|
+
return null;
|
|
13
|
+
},
|
|
14
|
+
get nativeBuildVersion(): null {
|
|
15
|
+
return null;
|
|
16
|
+
},
|
|
17
|
+
get androidId(): null {
|
|
18
|
+
return null;
|
|
19
|
+
},
|
|
20
|
+
async getInstallationTimeAsync(): Promise<null> {
|
|
21
|
+
return null;
|
|
22
|
+
},
|
|
23
|
+
};
|
package/tsconfig.json
ADDED
package/unimodule.json
ADDED