@ohos-ports/react-native-firebase-dynamic-links 0.0.0-stage → 22.4.0-beta.0
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 +971 -0
- package/LICENSE +32 -0
- package/README.md +53 -2
- package/RNFBDynamicLinks.podspec +49 -0
- package/android/.editorconfig +10 -0
- package/android/build.gradle +98 -0
- package/android/lint.xml +5 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/java/io/invertase/firebase/dynamiclinks/ReactNativeFirebaseDynamicLinksModule.java +507 -0
- package/android/src/main/java/io/invertase/firebase/dynamiclinks/ReactNativeFirebaseDynamicLinksPackage.java +44 -0
- package/app.plugin.js +1 -0
- package/ios/RNFBDynamicLinks/RNFBDynamicLinksAppDelegateInterceptor.h +37 -0
- package/ios/RNFBDynamicLinks/RNFBDynamicLinksAppDelegateInterceptor.m +132 -0
- package/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.h +28 -0
- package/ios/RNFBDynamicLinks/RNFBDynamicLinksModule.m +443 -0
- package/ios/RNFBDynamicLinks.xcodeproj/project.pbxproj +354 -0
- package/ios/RNFBDynamicLinks.xcodeproj/xcshareddata/IDETemplateMacros.plist +24 -0
- package/lib/builder.js +93 -0
- package/lib/builders/analytics.js +61 -0
- package/lib/builders/android.js +52 -0
- package/lib/builders/ios.js +76 -0
- package/lib/builders/itunes.js +49 -0
- package/lib/builders/navigation.js +37 -0
- package/lib/builders/otherPlatform.js +20 -0
- package/lib/builders/social.js +49 -0
- package/lib/index.d.ts +650 -0
- package/lib/index.js +119 -0
- package/lib/modular/index.d.ts +148 -0
- package/lib/modular/index.js +110 -0
- package/lib/version.js +2 -0
- package/package.json +42 -4
- package/plugin/build/index.d.ts +3 -0
- package/plugin/build/index.js +17 -0
- package/plugin/build/ios/appDelegate.d.ts +5 -0
- package/plugin/build/ios/appDelegate.js +86 -0
- package/plugin/build/ios/index.d.ts +2 -0
- package/plugin/build/ios/index.js +13 -0
- package/plugin/src/index.ts +15 -0
- package/plugin/src/ios/appDelegate.ts +92 -0
- package/plugin/src/ios/index.ts +3 -0
- package/plugin/tsconfig.json +9 -0
- package/plugin/tsconfig.tsbuildinfo +1 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
ShortLinkType: true,
|
|
8
|
+
SDK_VERSION: true,
|
|
9
|
+
firebase: true
|
|
10
|
+
};
|
|
11
|
+
exports.firebase = exports.default = exports.ShortLinkType = exports.SDK_VERSION = void 0;
|
|
12
|
+
var _internal = require("@react-native-firebase/app/lib/internal");
|
|
13
|
+
var _common = require("@react-native-firebase/app/lib/common");
|
|
14
|
+
var _builder = require("./builder");
|
|
15
|
+
var _version = require("./version");
|
|
16
|
+
var _modular = require("./modular");
|
|
17
|
+
Object.keys(_modular).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
|
+
if (key in exports && exports[key] === _modular[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _modular[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
/*
|
|
29
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
30
|
+
*
|
|
31
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
32
|
+
* you may not use this library except in compliance with the License.
|
|
33
|
+
* You may obtain a copy of the License at
|
|
34
|
+
*
|
|
35
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
36
|
+
*
|
|
37
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
38
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
39
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
40
|
+
* See the License for the specific language governing permissions and
|
|
41
|
+
* limitations under the License.
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
const ShortLinkType = exports.ShortLinkType = {
|
|
46
|
+
SHORT: 'SHORT',
|
|
47
|
+
UNGUESSABLE: 'UNGUESSABLE',
|
|
48
|
+
DEFAULT: 'DEFAULT'
|
|
49
|
+
};
|
|
50
|
+
const statics = {
|
|
51
|
+
ShortLinkType
|
|
52
|
+
};
|
|
53
|
+
const namespace = 'dynamicLinks';
|
|
54
|
+
const nativeModuleName = 'RNFBDynamicLinksModule';
|
|
55
|
+
const nativeEvents = ['dynamic_links_link_received'];
|
|
56
|
+
class FirebaseLinksModule extends _internal.FirebaseModule {
|
|
57
|
+
buildLink(dynamicLinkParams) {
|
|
58
|
+
let params;
|
|
59
|
+
try {
|
|
60
|
+
params = (0, _builder.default)(dynamicLinkParams);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
throw new Error(`firebase.dynamicLinks().buildLink(*) ${error.message}`);
|
|
63
|
+
}
|
|
64
|
+
return this.native.buildLink(params);
|
|
65
|
+
}
|
|
66
|
+
buildShortLink(dynamicLinkParams, shortLinkType = 'DEFAULT') {
|
|
67
|
+
let params;
|
|
68
|
+
try {
|
|
69
|
+
params = (0, _builder.default)(dynamicLinkParams);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
throw new Error(`firebase.dynamicLinks().buildShortLink(*) ${error.message}`);
|
|
72
|
+
}
|
|
73
|
+
if (shortLinkType !== 'DEFAULT' && shortLinkType !== 'SHORT' && shortLinkType !== 'UNGUESSABLE') {
|
|
74
|
+
throw new Error("firebase.dynamicLinks().buildShortLink(_, *) 'shortLinkType' expected one of DEFAULT, SHORT or UNGUESSABLE.");
|
|
75
|
+
}
|
|
76
|
+
return this.native.buildShortLink(params, shortLinkType);
|
|
77
|
+
}
|
|
78
|
+
getInitialLink() {
|
|
79
|
+
return this.native.getInitialLink();
|
|
80
|
+
}
|
|
81
|
+
onLink(listener) {
|
|
82
|
+
// TODO(salakar) rework internals as without this native module will never be ready (therefore never subscribes)
|
|
83
|
+
this.native;
|
|
84
|
+
const subscription = this.emitter.addListener('dynamic_links_link_received', event => listener(event));
|
|
85
|
+
return () => {
|
|
86
|
+
subscription.remove();
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
performDiagnostics() {
|
|
90
|
+
if (_common.isIOS) {
|
|
91
|
+
return this.native.performDiagnostics();
|
|
92
|
+
}
|
|
93
|
+
Promise.resolve();
|
|
94
|
+
}
|
|
95
|
+
resolveLink(link) {
|
|
96
|
+
if (!link) {
|
|
97
|
+
throw new Error('firebase.dynamicLinks().resolve(*) Invalid link parameter');
|
|
98
|
+
}
|
|
99
|
+
return this.native.resolveLink(link);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// import { SDK_VERSION } from '@react-native-firebase/dynamic-links';
|
|
103
|
+
const SDK_VERSION = exports.SDK_VERSION = _version.default || _version;
|
|
104
|
+
|
|
105
|
+
// import links from '@react-native-firebase/dynamic-links';
|
|
106
|
+
// links().X(...);
|
|
107
|
+
var _default = exports.default = (0, _internal.createModuleNamespace)({
|
|
108
|
+
statics,
|
|
109
|
+
version: _version.default || _version,
|
|
110
|
+
namespace,
|
|
111
|
+
nativeEvents,
|
|
112
|
+
nativeModuleName,
|
|
113
|
+
hasMultiAppSupport: false,
|
|
114
|
+
hasCustomUrlOrRegionSupport: false,
|
|
115
|
+
ModuleClass: FirebaseLinksModule
|
|
116
|
+
}); // import links, { firebase } from '@react-native-firebase/dynamic-links';
|
|
117
|
+
// links().X(...);
|
|
118
|
+
// firebase.links().X(...);
|
|
119
|
+
const firebase = exports.firebase = (0, _internal.getFirebaseRoot)();
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { ReactNativeFirebase } from '@react-native-firebase/app';
|
|
2
|
+
import { FirebaseDynamicLinksTypes } from '..';
|
|
3
|
+
|
|
4
|
+
type FirebaseDynamicLinks = FirebaseDynamicLinksTypes.Module;
|
|
5
|
+
|
|
6
|
+
export declare const ShortLinkType = FirebaseDynamicLinksTypes.ShortLinkType;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns an instance of DynamicLinks.
|
|
10
|
+
*
|
|
11
|
+
* #### Example
|
|
12
|
+
* ```js
|
|
13
|
+
* const dynamicLinks = getDynamicLinks();
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function getDynamicLinks(
|
|
17
|
+
app?: ReactNativeFirebase.FirebaseApp,
|
|
18
|
+
): FirebaseDynamicLinks;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Builds a Dynamic Link from the provided DynamicLinkParameters instances.
|
|
22
|
+
*
|
|
23
|
+
* #### Example
|
|
24
|
+
*
|
|
25
|
+
* ```js
|
|
26
|
+
* const dynamicLinks = getDynamicLinks();
|
|
27
|
+
* const link = await buildLink(dynamicLinks, {
|
|
28
|
+
* link: 'https://invertase.io',
|
|
29
|
+
* domainUriPrefix: 'https://xyz.page.link',
|
|
30
|
+
* analytics: {
|
|
31
|
+
* campaign: 'banner',
|
|
32
|
+
* }
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildLink(
|
|
37
|
+
dynamicLinks: FirebaseDynamicLinks,
|
|
38
|
+
dynamicLinkParams: FirebaseDynamicLinksTypes.DynamicLinkParameters,
|
|
39
|
+
): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Builds a short Dynamic Link from the provided DynamicLinkParameters interface.
|
|
42
|
+
*
|
|
43
|
+
* ```js
|
|
44
|
+
* const dynamicLinks = getDynamicLinks();
|
|
45
|
+
* const link = await buildShortLink(
|
|
46
|
+
* dynamicLinks,
|
|
47
|
+
* {
|
|
48
|
+
* link: 'https://invertase.io',
|
|
49
|
+
* domainUriPrefix: 'https://xyz.page.link',
|
|
50
|
+
* analytics: {
|
|
51
|
+
* campaign: 'banner',
|
|
52
|
+
* }
|
|
53
|
+
* },
|
|
54
|
+
* ShortLinkType.UNGUESSABLE,
|
|
55
|
+
* );
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function buildShortLink(
|
|
59
|
+
dynamicLinks: FirebaseDynamicLinks,
|
|
60
|
+
dynamicLinkParams: FirebaseDynamicLinksTypes.DynamicLinkParameters,
|
|
61
|
+
shortLinkType?: FirebaseDynamicLinksTypes.ShortLinkType,
|
|
62
|
+
): Promise<string>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Returns the Dynamic Link that the app has been launched from. If the app was not launched from a Dynamic Link the value will be null.
|
|
66
|
+
*
|
|
67
|
+
* > Use {@link auth#isSignInWithEmailLink} to check if an inbound dynamic link is an email sign-in link.
|
|
68
|
+
*
|
|
69
|
+
* #### Example
|
|
70
|
+
*
|
|
71
|
+
* ```js
|
|
72
|
+
* async function bootstrapApp() {
|
|
73
|
+
* const dynamicLinks = getDynamicLinks();
|
|
74
|
+
* const initialLink = await getInitialLink(dynamicLinks);
|
|
75
|
+
*
|
|
76
|
+
* if (initialLink) {
|
|
77
|
+
* // Handle dynamic link inside your own application
|
|
78
|
+
* if (initialLink.url === 'https://invertase.io/offer') return navigateTo('/offers')
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function getInitialLink(
|
|
84
|
+
dynamicLinks: FirebaseDynamicLinks,
|
|
85
|
+
): Promise<FirebaseDynamicLinksTypes.DynamicLink | null>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Subscribe to Dynamic Link open events while the app is still running.
|
|
89
|
+
*
|
|
90
|
+
* The listener is called from Dynamic Link open events whilst the app is still running, use
|
|
91
|
+
* {@link dynamic-links#getInitialLink} for Dynamic Links which cause the app to open from a previously closed / not running state.
|
|
92
|
+
*
|
|
93
|
+
* #### Example
|
|
94
|
+
*
|
|
95
|
+
* ```jsx
|
|
96
|
+
* function App() {
|
|
97
|
+
* const handleDynamicLink = (link) => {
|
|
98
|
+
* // Handle dynamic link inside your own application
|
|
99
|
+
* if (link.url === 'https://invertase.io/offer') return navigateTo('/offers')
|
|
100
|
+
* };
|
|
101
|
+
*
|
|
102
|
+
* useEffect(() => {
|
|
103
|
+
* const dynamicLinks = getDynamicLinks();
|
|
104
|
+
* const unsubscribe = onLink(dynamicLinks, handleDynamicLink);
|
|
105
|
+
* // When the component unmounts, remove the listener
|
|
106
|
+
* return unsubscribe;
|
|
107
|
+
* }, []);
|
|
108
|
+
*
|
|
109
|
+
* return <YourApp />;
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare function onLink(
|
|
114
|
+
dynamicLinks: FirebaseDynamicLinks,
|
|
115
|
+
listener: (link: FirebaseDynamicLinksTypes.DynamicLink) => void,
|
|
116
|
+
): () => void;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Perform built-in diagnostics on iOS. This is best performed on a real device running
|
|
120
|
+
* a build from Xcode so you may see the output easily. Alternatively it should be visible
|
|
121
|
+
* in Console.app with an iPhone plugged into a macOS computer
|
|
122
|
+
*
|
|
123
|
+
* NOTE: iOS only
|
|
124
|
+
*/
|
|
125
|
+
export declare function performDiagnostics(dynamicLinks: FirebaseDynamicLinks): void;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Resolve a given dynamic link (short or long) directly.
|
|
129
|
+
*
|
|
130
|
+
* This mimics the result of external link resolution, app open, and the DynamicLink you
|
|
131
|
+
* would get from {@link dynamic-links#getInitialLink}
|
|
132
|
+
*
|
|
133
|
+
* #### Example
|
|
134
|
+
*
|
|
135
|
+
* ```js
|
|
136
|
+
* const dynamicLinks = getDynamicLinks();
|
|
137
|
+
* const link = await resolveLink(dynamicLinks, 'https://reactnativefirebase.page.link/76adfasdf');
|
|
138
|
+
* console.log('Received link with URL: ' + link.url);
|
|
139
|
+
* ```
|
|
140
|
+
*
|
|
141
|
+
* Can throw error with message 'Invalid link parameter' if link parameter is null
|
|
142
|
+
* Can throw error with code 'not-found' if the link does not resolve
|
|
143
|
+
* Can throw error with code 'resolve-link-error' if there is a processing error
|
|
144
|
+
*/
|
|
145
|
+
export declare function resolveLink(
|
|
146
|
+
dynamicLinks: FirebaseDynamicLinks,
|
|
147
|
+
link: string,
|
|
148
|
+
): Promise<FirebaseDynamicLinksTypes.DynamicLink>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ShortLinkType", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _.ShortLinkType;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.buildLink = buildLink;
|
|
13
|
+
exports.buildShortLink = buildShortLink;
|
|
14
|
+
exports.getDynamicLinks = getDynamicLinks;
|
|
15
|
+
exports.getInitialLink = getInitialLink;
|
|
16
|
+
exports.onLink = onLink;
|
|
17
|
+
exports.performDiagnostics = performDiagnostics;
|
|
18
|
+
exports.resolveLink = resolveLink;
|
|
19
|
+
var _app = require("@react-native-firebase/app");
|
|
20
|
+
var _ = require("..");
|
|
21
|
+
/*
|
|
22
|
+
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
23
|
+
*
|
|
24
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
25
|
+
* you may not use this library except in compliance with the License.
|
|
26
|
+
* You may obtain a copy of the License at
|
|
27
|
+
*
|
|
28
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
29
|
+
*
|
|
30
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
31
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
32
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
33
|
+
* See the License for the specific language governing permissions and
|
|
34
|
+
* limitations under the License.
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {import("..").FirebaseApp} FirebaseApp
|
|
40
|
+
* @typedef {import("..").FirebaseDynamicLinksTypes.ShortLinkType} ShortLinkType
|
|
41
|
+
* @typedef {import("..").FirebaseDynamicLinksTypes.DynamicLink} DynamicLink
|
|
42
|
+
* @typedef {import("..").FirebaseDynamicLinksTypes.DynamicLinkParameters} DynamicLinkParameters
|
|
43
|
+
* @typedef {import("..").FirebaseDynamicLinksTypes.Module} FirebaseDynamicLinks
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
// FIXME these are duplicated from the non-modular types and should be by reference
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @returns {FirebaseDynamicLinks}
|
|
50
|
+
*/
|
|
51
|
+
function getDynamicLinks() {
|
|
52
|
+
return (0, _app.getApp)().dynamicLinks();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param {FirebaseDynamicLinks} dynamicLinks
|
|
58
|
+
* @param {DynamicLinkParameters} dynamicLinkParams
|
|
59
|
+
* @returns {Promise<string>}
|
|
60
|
+
*/
|
|
61
|
+
function buildLink(dynamicLinks, dynamicLinkParams) {
|
|
62
|
+
return dynamicLinks.buildLink(dynamicLinkParams);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @param {FirebaseDynamicLinks} dynamicLinks
|
|
68
|
+
* @param {DynamicLinkParameters} dynamicLinkParams
|
|
69
|
+
* @param {ShortLinkType | undefined} shortLinkType
|
|
70
|
+
* @returns {Promise<string>}
|
|
71
|
+
*/
|
|
72
|
+
function buildShortLink(dynamicLinks, dynamicLinkParams, shortLinkType) {
|
|
73
|
+
return dynamicLinks.buildShortLink(dynamicLinkParams, shortLinkType);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {FirebaseDynamicLinks} dynamicLinks
|
|
78
|
+
* @returns {Promise<DynamicLink | null>}
|
|
79
|
+
*/
|
|
80
|
+
function getInitialLink(dynamicLinks) {
|
|
81
|
+
return dynamicLinks.getInitialLink();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @param {FirebaseDynamicLinks} dynamicLinks
|
|
86
|
+
* @param {(link: DynamicLink) => void} listener
|
|
87
|
+
* @returns {() => void}
|
|
88
|
+
*/
|
|
89
|
+
function onLink(dynamicLinks, listener) {
|
|
90
|
+
return dynamicLinks.onLink(listener);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
* @param {FirebaseDynamicLinks} dynamicLinks
|
|
96
|
+
* @returns {void}
|
|
97
|
+
*/
|
|
98
|
+
function performDiagnostics(dynamicLinks) {
|
|
99
|
+
return dynamicLinks.performDiagnostics();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
* @param {FirebaseDynamicLinks} dynamicLinks
|
|
105
|
+
* @param {string} link
|
|
106
|
+
* @returns {Promise<DynamicLink>}
|
|
107
|
+
*/
|
|
108
|
+
function resolveLink(dynamicLinks, link) {
|
|
109
|
+
return dynamicLinks.resolveLink(link);
|
|
110
|
+
}
|
package/lib/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-ports/react-native-firebase-dynamic-links",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "22.4.0-beta.0",
|
|
4
|
+
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
|
5
|
+
"description": "React Native Firebase - Dynamic Links",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "genversion --semi lib/version.js",
|
|
10
|
+
"build:clean": "rimraf android/build && rimraf ios/build",
|
|
11
|
+
"build:plugin": "rimraf plugin/build && tsc --build plugin",
|
|
12
|
+
"lint:plugin": "eslint plugin/src/*",
|
|
13
|
+
"prepare": "yarn run build && npm run build:plugin"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/ohos-ports/ohos-ports.git",
|
|
18
|
+
"directory": "ports/@react-native-firebase/dynamic-links/22.4.0"
|
|
19
|
+
},
|
|
20
|
+
"license": "Apache-2.0",
|
|
21
|
+
"keywords": [
|
|
22
|
+
"react",
|
|
23
|
+
"react-native",
|
|
24
|
+
"firebase",
|
|
25
|
+
"deep link",
|
|
26
|
+
"dynamic link"
|
|
27
|
+
],
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@react-native-firebase/app": "22.4.0",
|
|
30
|
+
"@ohos-ports/expo": "^57.0.24-beta.6"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@ohos-ports/expo": "^57.0.24-beta.6"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"@ohos-ports/expo": {
|
|
37
|
+
"optional": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "7eaaf185aab15c7e4fc3c218af9be609fe7e0030"
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
7
|
+
const ios_1 = require("./ios");
|
|
8
|
+
/**
|
|
9
|
+
* A config plugin for configuring `@react-native-firebase/dynamic-links`
|
|
10
|
+
*/
|
|
11
|
+
const withRnFirebaseDynamicLinks = config => {
|
|
12
|
+
return (0, config_plugins_1.withPlugins)(config, [
|
|
13
|
+
// iOS
|
|
14
|
+
ios_1.withFirebaseAppDelegate]);
|
|
15
|
+
};
|
|
16
|
+
const pak = require('@react-native-firebase/dynamic-links/package.json');
|
|
17
|
+
exports.default = (0, config_plugins_1.createRunOncePlugin)(withRnFirebaseDynamicLinks, pak.name, pak.version);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
import { AppDelegateProjectFile } from '@expo/config-plugins/build/ios/Paths';
|
|
3
|
+
export declare function modifyObjcAppDelegate(contents: string): string;
|
|
4
|
+
export declare function modifyAppDelegateAsync(appDelegateFileInfo: AppDelegateProjectFile): Promise<void>;
|
|
5
|
+
export declare const withFirebaseAppDelegate: ConfigPlugin;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
"default": mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
exports.withFirebaseAppDelegate = void 0;
|
|
12
|
+
exports.modifyObjcAppDelegate = modifyObjcAppDelegate;
|
|
13
|
+
exports.modifyAppDelegateAsync = modifyAppDelegateAsync;
|
|
14
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
15
|
+
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const methodInvocationBlock = `[RNFBDynamicLinksAppDelegateInterceptor sharedInstance];`;
|
|
18
|
+
// https://regex101.com/r/mPgaq6/1
|
|
19
|
+
const methodInvocationLineMatcher = /(?:self\.moduleName\s*=\s*@\"([^"]*)\";)|(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[(\[RCTBridge alloc\]|self\.reactDelegate))/g;
|
|
20
|
+
// https://regex101.com/r/nHrTa9/1/
|
|
21
|
+
// if the above regex fails, we can use this one as a fallback:
|
|
22
|
+
const fallbackInvocationLineMatcher = /-\s*\(BOOL\)\s*application:\s*\(UIApplication\s*\*\s*\)\s*\w+\s+didFinishLaunchingWithOptions:/g;
|
|
23
|
+
function modifyObjcAppDelegate(contents) {
|
|
24
|
+
// Add import
|
|
25
|
+
if (!contents.includes('#import <RNFBDynamicLinksAppDelegateInterceptor.h>')) {
|
|
26
|
+
contents = contents.replace(/#import "AppDelegate.h"/g, `#import "AppDelegate.h"
|
|
27
|
+
#import <RNFBDynamicLinksAppDelegateInterceptor.h>`);
|
|
28
|
+
}
|
|
29
|
+
// To avoid potential issues with existing changes from older plugin versions
|
|
30
|
+
if (contents.includes(methodInvocationBlock)) {
|
|
31
|
+
return contents;
|
|
32
|
+
}
|
|
33
|
+
if (!methodInvocationLineMatcher.test(contents) && !fallbackInvocationLineMatcher.test(contents)) {
|
|
34
|
+
config_plugins_1.WarningAggregator.addWarningIOS('@react-native-firebase/dynamic-links', 'Unable to determine correct Firebase insertion point in AppDelegate.m. Skipping Firebase addition.');
|
|
35
|
+
return contents;
|
|
36
|
+
}
|
|
37
|
+
// Add invocation
|
|
38
|
+
try {
|
|
39
|
+
return (0, generateCode_1.mergeContents)({
|
|
40
|
+
tag: '@react-native-firebase/dynamic-links-didFinishLaunchingWithOptions',
|
|
41
|
+
src: contents,
|
|
42
|
+
newSrc: methodInvocationBlock,
|
|
43
|
+
anchor: methodInvocationLineMatcher,
|
|
44
|
+
offset: 0,
|
|
45
|
+
// new line will be inserted right above matched anchor
|
|
46
|
+
comment: '//'
|
|
47
|
+
}).contents;
|
|
48
|
+
} catch (_) {
|
|
49
|
+
// tests if the opening `{` is in the new line
|
|
50
|
+
const multilineMatcher = new RegExp(fallbackInvocationLineMatcher.source + '.+\\n*{');
|
|
51
|
+
const isHeaderMultiline = multilineMatcher.test(contents);
|
|
52
|
+
// we fallback to another regex if the first one fails
|
|
53
|
+
return (0, generateCode_1.mergeContents)({
|
|
54
|
+
tag: '@react-native-firebase/app-didFinishLaunchingWithOptions-fallback',
|
|
55
|
+
src: contents,
|
|
56
|
+
newSrc: methodInvocationBlock,
|
|
57
|
+
anchor: fallbackInvocationLineMatcher,
|
|
58
|
+
// new line will be inserted right below matched anchor
|
|
59
|
+
// or two lines, if the `{` is in the new line
|
|
60
|
+
offset: isHeaderMultiline ? 2 : 1,
|
|
61
|
+
comment: '//'
|
|
62
|
+
}).contents;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function modifyAppDelegateAsync(appDelegateFileInfo) {
|
|
66
|
+
const {
|
|
67
|
+
language,
|
|
68
|
+
path,
|
|
69
|
+
contents
|
|
70
|
+
} = appDelegateFileInfo;
|
|
71
|
+
if (['objc', 'objcpp'].includes(language)) {
|
|
72
|
+
const newContents = modifyObjcAppDelegate(contents);
|
|
73
|
+
await fs_1.default.promises.writeFile(path, newContents);
|
|
74
|
+
} else {
|
|
75
|
+
// TODO: Support Swift
|
|
76
|
+
throw new Error(`Cannot add Firebase code to AppDelegate of language "${language}"`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const withFirebaseAppDelegate = config => {
|
|
80
|
+
return (0, config_plugins_1.withDangerousMod)(config, ['ios', async config => {
|
|
81
|
+
const fileInfo = config_plugins_1.IOSConfig.Paths.getAppDelegate(config.modRequest.projectRoot);
|
|
82
|
+
await modifyAppDelegateAsync(fileInfo);
|
|
83
|
+
return config;
|
|
84
|
+
}]);
|
|
85
|
+
};
|
|
86
|
+
exports.withFirebaseAppDelegate = withFirebaseAppDelegate;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withFirebaseAppDelegate = void 0;
|
|
7
|
+
const appDelegate_1 = require("./appDelegate");
|
|
8
|
+
Object.defineProperty(exports, "withFirebaseAppDelegate", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return appDelegate_1.withFirebaseAppDelegate;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ConfigPlugin, withPlugins, createRunOncePlugin } from '@expo/config-plugins';
|
|
2
|
+
import { withFirebaseAppDelegate } from './ios';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A config plugin for configuring `@react-native-firebase/dynamic-links`
|
|
6
|
+
*/
|
|
7
|
+
const withRnFirebaseDynamicLinks: ConfigPlugin = config => {
|
|
8
|
+
return withPlugins(config, [
|
|
9
|
+
// iOS
|
|
10
|
+
withFirebaseAppDelegate,
|
|
11
|
+
]);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const pak = require('@react-native-firebase/dynamic-links/package.json');
|
|
15
|
+
export default createRunOncePlugin(withRnFirebaseDynamicLinks, pak.name, pak.version);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ConfigPlugin, IOSConfig, WarningAggregator, withDangerousMod } from '@expo/config-plugins';
|
|
2
|
+
import { AppDelegateProjectFile } from '@expo/config-plugins/build/ios/Paths';
|
|
3
|
+
import { mergeContents } from '@expo/config-plugins/build/utils/generateCode';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
|
|
6
|
+
const methodInvocationBlock = `[RNFBDynamicLinksAppDelegateInterceptor sharedInstance];`;
|
|
7
|
+
// https://regex101.com/r/mPgaq6/1
|
|
8
|
+
const methodInvocationLineMatcher =
|
|
9
|
+
/(?:self\.moduleName\s*=\s*@\"([^"]*)\";)|(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[(\[RCTBridge alloc\]|self\.reactDelegate))/g;
|
|
10
|
+
|
|
11
|
+
// https://regex101.com/r/nHrTa9/1/
|
|
12
|
+
// if the above regex fails, we can use this one as a fallback:
|
|
13
|
+
const fallbackInvocationLineMatcher =
|
|
14
|
+
/-\s*\(BOOL\)\s*application:\s*\(UIApplication\s*\*\s*\)\s*\w+\s+didFinishLaunchingWithOptions:/g;
|
|
15
|
+
|
|
16
|
+
export function modifyObjcAppDelegate(contents: string): string {
|
|
17
|
+
// Add import
|
|
18
|
+
if (!contents.includes('#import <RNFBDynamicLinksAppDelegateInterceptor.h>')) {
|
|
19
|
+
contents = contents.replace(
|
|
20
|
+
/#import "AppDelegate.h"/g,
|
|
21
|
+
`#import "AppDelegate.h"
|
|
22
|
+
#import <RNFBDynamicLinksAppDelegateInterceptor.h>`,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// To avoid potential issues with existing changes from older plugin versions
|
|
27
|
+
if (contents.includes(methodInvocationBlock)) {
|
|
28
|
+
return contents;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (
|
|
32
|
+
!methodInvocationLineMatcher.test(contents) &&
|
|
33
|
+
!fallbackInvocationLineMatcher.test(contents)
|
|
34
|
+
) {
|
|
35
|
+
WarningAggregator.addWarningIOS(
|
|
36
|
+
'@react-native-firebase/dynamic-links',
|
|
37
|
+
'Unable to determine correct Firebase insertion point in AppDelegate.m. Skipping Firebase addition.',
|
|
38
|
+
);
|
|
39
|
+
return contents;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Add invocation
|
|
43
|
+
try {
|
|
44
|
+
return mergeContents({
|
|
45
|
+
tag: '@react-native-firebase/dynamic-links-didFinishLaunchingWithOptions',
|
|
46
|
+
src: contents,
|
|
47
|
+
newSrc: methodInvocationBlock,
|
|
48
|
+
anchor: methodInvocationLineMatcher,
|
|
49
|
+
offset: 0, // new line will be inserted right above matched anchor
|
|
50
|
+
comment: '//',
|
|
51
|
+
}).contents;
|
|
52
|
+
} catch (_: any) {
|
|
53
|
+
// tests if the opening `{` is in the new line
|
|
54
|
+
const multilineMatcher = new RegExp(fallbackInvocationLineMatcher.source + '.+\\n*{');
|
|
55
|
+
const isHeaderMultiline = multilineMatcher.test(contents);
|
|
56
|
+
|
|
57
|
+
// we fallback to another regex if the first one fails
|
|
58
|
+
return mergeContents({
|
|
59
|
+
tag: '@react-native-firebase/app-didFinishLaunchingWithOptions-fallback',
|
|
60
|
+
src: contents,
|
|
61
|
+
newSrc: methodInvocationBlock,
|
|
62
|
+
anchor: fallbackInvocationLineMatcher,
|
|
63
|
+
// new line will be inserted right below matched anchor
|
|
64
|
+
// or two lines, if the `{` is in the new line
|
|
65
|
+
offset: isHeaderMultiline ? 2 : 1,
|
|
66
|
+
comment: '//',
|
|
67
|
+
}).contents;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function modifyAppDelegateAsync(appDelegateFileInfo: AppDelegateProjectFile) {
|
|
72
|
+
const { language, path, contents } = appDelegateFileInfo;
|
|
73
|
+
|
|
74
|
+
if (['objc', 'objcpp'].includes(language)) {
|
|
75
|
+
const newContents = modifyObjcAppDelegate(contents);
|
|
76
|
+
await fs.promises.writeFile(path, newContents);
|
|
77
|
+
} else {
|
|
78
|
+
// TODO: Support Swift
|
|
79
|
+
throw new Error(`Cannot add Firebase code to AppDelegate of language "${language}"`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const withFirebaseAppDelegate: ConfigPlugin = config => {
|
|
84
|
+
return withDangerousMod(config, [
|
|
85
|
+
'ios',
|
|
86
|
+
async config => {
|
|
87
|
+
const fileInfo = IOSConfig.Paths.getAppDelegate(config.modRequest.projectRoot);
|
|
88
|
+
await modifyAppDelegateAsync(fileInfo);
|
|
89
|
+
return config;
|
|
90
|
+
},
|
|
91
|
+
]);
|
|
92
|
+
};
|