@angular/fire 7.5.0 → 7.6.0-canary.34e89a4
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/README.md +95 -74
- package/analytics/is-analytics-supported-factory.d.ts +4 -0
- package/bundles/angular-fire-analytics.umd.js +41 -31
- package/bundles/angular-fire-analytics.umd.js.map +1 -1
- package/bundles/angular-fire-app-check.umd.js +14 -18
- package/bundles/angular-fire-app-check.umd.js.map +1 -1
- package/bundles/angular-fire-app.umd.js +14 -18
- package/bundles/angular-fire-app.umd.js.map +1 -1
- package/bundles/angular-fire-auth-guard.umd.js +5 -7
- package/bundles/angular-fire-auth-guard.umd.js.map +1 -1
- package/bundles/angular-fire-auth.umd.js +64 -68
- package/bundles/angular-fire-auth.umd.js.map +1 -1
- package/bundles/angular-fire-compat-analytics.umd.js +11 -13
- package/bundles/angular-fire-compat-analytics.umd.js.map +1 -1
- package/bundles/angular-fire-compat-auth-guard.umd.js +6 -8
- package/bundles/angular-fire-compat-auth-guard.umd.js.map +1 -1
- package/bundles/angular-fire-compat-auth.umd.js +11 -13
- package/bundles/angular-fire-compat-auth.umd.js.map +1 -1
- package/bundles/angular-fire-compat-database.umd.js +9 -11
- package/bundles/angular-fire-compat-database.umd.js.map +1 -1
- package/bundles/angular-fire-compat-firestore.umd.js +9 -11
- package/bundles/angular-fire-compat-firestore.umd.js.map +1 -1
- package/bundles/angular-fire-compat-functions.umd.js +9 -11
- package/bundles/angular-fire-compat-functions.umd.js.map +1 -1
- package/bundles/angular-fire-compat-messaging.umd.js +8 -10
- package/bundles/angular-fire-compat-messaging.umd.js.map +1 -1
- package/bundles/angular-fire-compat-performance.umd.js +8 -10
- package/bundles/angular-fire-compat-performance.umd.js.map +1 -1
- package/bundles/angular-fire-compat-remote-config.umd.js +9 -11
- package/bundles/angular-fire-compat-remote-config.umd.js.map +1 -1
- package/bundles/angular-fire-compat-storage.umd.js +8 -10
- package/bundles/angular-fire-compat-storage.umd.js.map +1 -1
- package/bundles/angular-fire-compat.umd.js +13 -15
- package/bundles/angular-fire-compat.umd.js.map +1 -1
- package/bundles/angular-fire-database.umd.js +59 -67
- package/bundles/angular-fire-database.umd.js.map +1 -1
- package/bundles/angular-fire-firestore-lite.umd.js +50 -54
- package/bundles/angular-fire-firestore-lite.umd.js.map +1 -1
- package/bundles/angular-fire-firestore.umd.js +67 -71
- package/bundles/angular-fire-firestore.umd.js.map +1 -1
- package/bundles/angular-fire-functions.umd.js +15 -19
- package/bundles/angular-fire-functions.umd.js.map +1 -1
- package/bundles/angular-fire-messaging.umd.js +33 -23
- package/bundles/angular-fire-messaging.umd.js.map +1 -1
- package/bundles/angular-fire-performance.umd.js +17 -21
- package/bundles/angular-fire-performance.umd.js.map +1 -1
- package/bundles/angular-fire-remote-config.umd.js +47 -37
- package/bundles/angular-fire-remote-config.umd.js.map +1 -1
- package/bundles/angular-fire-storage.umd.js +27 -31
- package/bundles/angular-fire-storage.umd.js.map +1 -1
- package/bundles/angular-fire.umd.js +16 -59
- package/bundles/angular-fire.umd.js.map +1 -1
- package/compat/firestore/interfaces.d.ts +4 -4
- package/core.d.ts +1 -12
- package/docs/analytics.md +67 -0
- package/docs/app-check.md +53 -0
- package/docs/auth.md +165 -0
- package/docs/{analytics → compat/analytics}/getting-started.md +2 -0
- package/docs/{auth → compat/auth}/getting-started.md +2 -0
- package/docs/{auth → compat/auth}/router-guards.md +2 -0
- package/docs/{emulators → compat/emulators}/emulators.md +2 -0
- package/docs/{firestore → compat/firestore}/collections.md +2 -0
- package/docs/{firestore → compat/firestore}/documents.md +2 -0
- package/docs/{firestore → compat/firestore}/offline-data.md +2 -0
- package/docs/{firestore → compat/firestore}/querying-collections.md +2 -0
- package/docs/{functions → compat/functions}/functions.md +2 -0
- package/docs/{messaging → compat/messaging}/messaging.md +2 -0
- package/docs/{performance → compat/performance}/getting-started.md +2 -0
- package/docs/{remote-config → compat/remote-config}/getting-started.md +2 -0
- package/docs/{rtdb → compat/rtdb}/lists.md +2 -0
- package/docs/{rtdb → compat/rtdb}/objects.md +2 -0
- package/docs/{rtdb → compat/rtdb}/querying-lists.md +2 -0
- package/docs/{storage → compat/storage}/storage.md +2 -0
- package/docs/compat.md +70 -0
- package/docs/database.md +175 -0
- package/docs/deploy/getting-started.md +2 -2
- package/docs/firestore.md +148 -0
- package/docs/functions.md +52 -0
- package/docs/images/analytics-illo_1x.png +0 -0
- package/docs/images/auth-illo_1x.png +0 -0
- package/docs/images/cloud-messaging-illo_1x.png +0 -0
- package/docs/images/database-illo_1x.png +0 -0
- package/docs/images/firestore-illo_1x.png +0 -0
- package/docs/images/functions-illo_1x.png +0 -0
- package/docs/images/hosting-illo_1x.png +0 -0
- package/docs/images/performance-illo_1x.png +0 -0
- package/docs/images/reCAPTCHA-logo@1x.png +0 -0
- package/docs/images/remote-config-illo_1x.png +0 -0
- package/docs/images/storage-illo_1x.png +0 -0
- package/docs/install-and-setup.md +39 -86
- package/docs/install-firebase-tools.md +78 -0
- package/docs/messaging.md +25 -0
- package/docs/performance.md +57 -0
- package/docs/remote-config.md +53 -0
- package/docs/storage.md +90 -0
- package/docs/universal/cloud-functions.md +27 -6
- package/docs/universal/getting-started.md +9 -134
- package/esm2015/analytics/analytics.module.js +7 -6
- package/esm2015/analytics/is-analytics-supported-factory.js +16 -0
- package/esm2015/analytics/overrides.js +3 -3
- package/esm2015/compat/firestore/interfaces.js +1 -1
- package/esm2015/core.js +3 -45
- package/esm2015/messaging/is-messaging-supported-factory.js +16 -0
- package/esm2015/messaging/messaging.module.js +7 -6
- package/esm2015/messaging/overrides.js +3 -3
- package/esm2015/remote-config/is-remote-config-supported-factory.js +16 -0
- package/esm2015/remote-config/overrides.js +3 -3
- package/esm2015/remote-config/remote-config.module.js +7 -6
- package/fesm2015/angular-fire-analytics.js +21 -7
- package/fesm2015/angular-fire-analytics.js.map +1 -1
- package/fesm2015/angular-fire-app-check.js.map +1 -1
- package/fesm2015/angular-fire-app.js.map +1 -1
- package/fesm2015/angular-fire-auth-guard.js.map +1 -1
- package/fesm2015/angular-fire-auth.js.map +1 -1
- package/fesm2015/angular-fire-compat-analytics.js.map +1 -1
- package/fesm2015/angular-fire-compat-auth-guard.js.map +1 -1
- package/fesm2015/angular-fire-compat-auth.js.map +1 -1
- package/fesm2015/angular-fire-compat-database.js +1 -1
- package/fesm2015/angular-fire-compat-database.js.map +1 -1
- package/fesm2015/angular-fire-compat-firestore.js +1 -1
- package/fesm2015/angular-fire-compat-firestore.js.map +1 -1
- package/fesm2015/angular-fire-compat-functions.js.map +1 -1
- package/fesm2015/angular-fire-compat-messaging.js.map +1 -1
- package/fesm2015/angular-fire-compat-performance.js.map +1 -1
- package/fesm2015/angular-fire-compat-remote-config.js.map +1 -1
- package/fesm2015/angular-fire-compat-storage.js.map +1 -1
- package/fesm2015/angular-fire-compat.js.map +1 -1
- package/fesm2015/angular-fire-database.js.map +1 -1
- package/fesm2015/angular-fire-firestore-lite.js.map +1 -1
- package/fesm2015/angular-fire-firestore.js.map +1 -1
- package/fesm2015/angular-fire-functions.js.map +1 -1
- package/fesm2015/angular-fire-messaging.js +21 -7
- package/fesm2015/angular-fire-messaging.js.map +1 -1
- package/fesm2015/angular-fire-performance.js.map +1 -1
- package/fesm2015/angular-fire-remote-config.js +22 -8
- package/fesm2015/angular-fire-remote-config.js.map +1 -1
- package/fesm2015/angular-fire-storage.js.map +1 -1
- package/fesm2015/angular-fire.js +3 -45
- package/fesm2015/angular-fire.js.map +1 -1
- package/messaging/is-messaging-supported-factory.d.ts +4 -0
- package/package.json +9 -10
- package/remote-config/is-remote-config-supported-factory.d.ts +4 -0
- package/schematics/deploy/actions.js +8 -3
- package/schematics/deploy/builder.js +2 -2
- package/schematics/firebaseTools.js +4 -2
- package/schematics/setup/index.js +58 -29
- package/schematics/setup/prompts.js +18 -46
- package/schematics/utils.js +32 -28
- package/docs/ionic/authentication.md +0 -104
- package/docs/ionic/cli.md +0 -218
- package/docs/ionic/v2.md +0 -531
- package/docs/ionic/v3.md +0 -705
- package/schematics/setup/ssr.js +0 -100
- package/schematics/setup/static.js +0 -78
|
@@ -243,61 +243,33 @@ const sitePrompt = ({ projectId: project }, options) => __awaiter(void 0, void 0
|
|
|
243
243
|
return (yield sites).find(it => common_1.shortSiteName(it) === siteName);
|
|
244
244
|
});
|
|
245
245
|
exports.sitePrompt = sitePrompt;
|
|
246
|
+
const DEFAULT_REGION = 'us-central1';
|
|
247
|
+
const ALLOWED_SSR_REGIONS = [
|
|
248
|
+
{ name: 'us-central1 (Iowa)', value: 'us-central1' },
|
|
249
|
+
{ name: 'us-west1 (Oregon)', value: 'us-west1' },
|
|
250
|
+
{ name: 'us-east1 (South Carolina)', value: 'us-east1' },
|
|
251
|
+
{ name: 'europe-west1 (Belgium)', value: 'europe-west1' },
|
|
252
|
+
{ name: 'asia-east1 (Taiwan)', value: 'asia-east1' },
|
|
253
|
+
];
|
|
246
254
|
const projectTypePrompt = (project, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
247
|
-
var _b, _c, _d, _e, _f, _g
|
|
248
|
-
let prerender = false;
|
|
249
|
-
let nodeVersion;
|
|
255
|
+
var _b, _c, _d, _e, _f, _g;
|
|
250
256
|
let serverTarget;
|
|
251
257
|
let browserTarget = `${name}:build:${((_c = (_b = project.architect) === null || _b === void 0 ? void 0 : _b.build) === null || _c === void 0 ? void 0 : _c.defaultConfiguration) || 'production'}`;
|
|
252
258
|
let prerenderTarget;
|
|
253
259
|
if (utils_1.isUniversalApp(project)) {
|
|
254
260
|
serverTarget = `${name}:server:${((_e = (_d = project.architect) === null || _d === void 0 ? void 0 : _d.server) === null || _e === void 0 ? void 0 : _e.defaultConfiguration) || 'production'}`;
|
|
255
261
|
browserTarget = `${name}:build:${((_g = (_f = project.architect) === null || _f === void 0 ? void 0 : _f.build) === null || _g === void 0 ? void 0 : _g.defaultConfiguration) || 'production'}`;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
type: 'confirm',
|
|
260
|
-
name: 'shouldPrerender',
|
|
261
|
-
message: 'Should we prerender before deployment?',
|
|
262
|
-
default: true
|
|
263
|
-
});
|
|
264
|
-
prerender = shouldPrerender;
|
|
265
|
-
}
|
|
266
|
-
const choices = [
|
|
267
|
-
{ name: prerender ? 'Pre-render only' : 'Don\'t render universal content', value: 0 },
|
|
268
|
-
{ name: 'Cloud Functions', value: 1 },
|
|
269
|
-
{ name: 'Cloud Run', value: 2 },
|
|
270
|
-
];
|
|
271
|
-
const { projectType } = yield inquirer.prompt({
|
|
262
|
+
const prerender = utils_1.hasPrerenderOption(project);
|
|
263
|
+
prerenderTarget = prerender && `${name}:prerender:${prerender.defaultConfiguration || 'production'}`;
|
|
264
|
+
const { ssrRegion } = yield inquirer.prompt({
|
|
272
265
|
type: 'list',
|
|
273
|
-
name: '
|
|
274
|
-
choices,
|
|
275
|
-
message: '
|
|
276
|
-
default:
|
|
266
|
+
name: 'ssrRegion',
|
|
267
|
+
choices: ALLOWED_SSR_REGIONS,
|
|
268
|
+
message: 'In which region would you like to host server-side content?',
|
|
269
|
+
default: DEFAULT_REGION,
|
|
277
270
|
});
|
|
278
|
-
|
|
279
|
-
const { newNodeVersion } = yield inquirer.prompt({
|
|
280
|
-
type: 'list',
|
|
281
|
-
name: 'newNodeVersion',
|
|
282
|
-
choices: ['12', '14', '16'],
|
|
283
|
-
message: 'What version of Node.js would you like to use?',
|
|
284
|
-
default: parseInt(process.versions.node, 10).toString(),
|
|
285
|
-
});
|
|
286
|
-
nodeVersion = newNodeVersion;
|
|
287
|
-
}
|
|
288
|
-
else if (projectType === 2) {
|
|
289
|
-
const fetch = require('node-fetch');
|
|
290
|
-
const { newNodeVersion } = yield inquirer.prompt({
|
|
291
|
-
type: 'input',
|
|
292
|
-
name: 'newNodeVersion',
|
|
293
|
-
message: 'What version of Node.js would you like to use?',
|
|
294
|
-
validate: it => fetch(`https://hub.docker.com/v2/repositories/library/node/tags/${it}-slim`).then(it => it.status === 200 || `Can't find node:${it}-slim docker image.`),
|
|
295
|
-
default: parseFloat(process.versions.node).toString(),
|
|
296
|
-
});
|
|
297
|
-
nodeVersion = newNodeVersion;
|
|
298
|
-
}
|
|
299
|
-
return { prerender, projectType, nodeVersion, browserTarget, serverTarget, prerenderTarget };
|
|
271
|
+
return { prerender, projectType: 3, ssrRegion, browserTarget, serverTarget, prerenderTarget };
|
|
300
272
|
}
|
|
301
|
-
return { projectType:
|
|
273
|
+
return { projectType: 3, browserTarget, serverTarget, prerenderTarget };
|
|
302
274
|
});
|
|
303
275
|
exports.projectTypePrompt = projectTypePrompt;
|
package/schematics/utils.js
CHANGED
|
@@ -80,39 +80,43 @@ const projectFromRc = (rc, target) => {
|
|
|
80
80
|
return [project || defaultProject, site];
|
|
81
81
|
};
|
|
82
82
|
function addEnvironmentEntry(host, filePath, data) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const change = new change_1.ReplaceChange(filePath, firebaseIdentifier.parent.pos, firebaseIdentifier.parent.getFullText(), data);
|
|
103
|
-
change_1.applyToUpdateRecorder(recorder, [change]);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
const openBracketToken = envObjectLiteral.getChildren().find(({ kind }) => kind === typescript_1.default.SyntaxKind.OpenBraceToken);
|
|
107
|
-
if (openBracketToken) {
|
|
108
|
-
const change = new change_1.InsertChange(filePath, openBracketToken.end, `${data},`);
|
|
83
|
+
const fileExists = host.exists(filePath);
|
|
84
|
+
if (fileExists) {
|
|
85
|
+
const buffer = host.read(filePath);
|
|
86
|
+
if (!buffer) {
|
|
87
|
+
throw new schematics_1.SchematicsException(`Cannot read ${filePath}`);
|
|
88
|
+
}
|
|
89
|
+
const sourceFile = typescript_1.default.createSourceFile(filePath, buffer.toString('utf-8'), typescript_1.default.ScriptTarget.Latest, true);
|
|
90
|
+
const envIdentifier = ast_utils_1.findNode(sourceFile, typescript_1.default.SyntaxKind.Identifier, 'environment');
|
|
91
|
+
if (!envIdentifier || !envIdentifier.parent) {
|
|
92
|
+
throw new schematics_1.SchematicsException(`Cannot find 'environment' identifier in ${filePath}`);
|
|
93
|
+
}
|
|
94
|
+
const envObjectLiteral = envIdentifier.parent.getChildren().find(({ kind }) => kind === typescript_1.default.SyntaxKind.ObjectLiteralExpression);
|
|
95
|
+
if (!envObjectLiteral) {
|
|
96
|
+
throw new schematics_1.SchematicsException(`${filePath} is not in the expected format`);
|
|
97
|
+
}
|
|
98
|
+
const firebaseIdentifier = ast_utils_1.findNode(envObjectLiteral, typescript_1.default.SyntaxKind.Identifier, 'firebase');
|
|
99
|
+
const recorder = host.beginUpdate(filePath);
|
|
100
|
+
if (firebaseIdentifier && firebaseIdentifier.parent) {
|
|
101
|
+
const change = new change_1.ReplaceChange(filePath, firebaseIdentifier.parent.pos, firebaseIdentifier.parent.getFullText(), data);
|
|
109
102
|
change_1.applyToUpdateRecorder(recorder, [change]);
|
|
110
103
|
}
|
|
111
104
|
else {
|
|
112
|
-
|
|
105
|
+
const openBracketToken = envObjectLiteral.getChildren().find(({ kind }) => kind === typescript_1.default.SyntaxKind.OpenBraceToken);
|
|
106
|
+
if (openBracketToken) {
|
|
107
|
+
const change = new change_1.InsertChange(filePath, openBracketToken.end, `${data},`);
|
|
108
|
+
change_1.applyToUpdateRecorder(recorder, [change]);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
throw new schematics_1.SchematicsException(`${filePath} is not in the expected format`);
|
|
112
|
+
}
|
|
113
113
|
}
|
|
114
|
+
host.commitUpdate(recorder);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
host.create(filePath, `export const environment = {${data},
|
|
118
|
+
};`);
|
|
114
119
|
}
|
|
115
|
-
host.commitUpdate(recorder);
|
|
116
120
|
return host;
|
|
117
121
|
}
|
|
118
122
|
exports.addEnvironmentEntry = addEnvironmentEntry;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# Step 1: install this plugin:
|
|
2
|
-
```
|
|
3
|
-
ionic cordova plugin add cordova-universal-links-plugin
|
|
4
|
-
ionic cordova plugin add cordova-plugin-buildinfo
|
|
5
|
-
ionic cordova plugin add cordova-plugin-browsertab
|
|
6
|
-
ionic cordova plugin add cordova-plugin-inappbrowser
|
|
7
|
-
(for ios)
|
|
8
|
-
ionic cordova plugin add cordova-plugin-customurlscheme
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
# Step 2: Add Firebase to your Ionic
|
|
12
|
-
|
|
13
|
-
**Install Firebase to Angular project**
|
|
14
|
-
|
|
15
|
-
Follow [this tutorial](https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md) to make a basic setup for your Ionic project.
|
|
16
|
-
|
|
17
|
-
**To set up in an Android app**
|
|
18
|
-
|
|
19
|
-
Go to [Firebase console](https://console.firebase.google.com/) then click **Add Firebase to your Android app** and follow the setup steps.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# Step 3: Set up Firebase Authentication for Cordova
|
|
23
|
-
|
|
24
|
-
*This is a summary from the [Firebase instructions](https://firebase.google.com/docs/auth/web/cordova).*
|
|
25
|
-
|
|
26
|
-
**Setup Dynamic Link**
|
|
27
|
-
In the Firebase console, open the **Dynamic Links** section at bottom left panel, setup by their instruction
|
|
28
|
-
|
|
29
|
-
**Add dynamic link**
|
|
30
|
-
*Add this to config.xml at root level of project:*
|
|
31
|
-
```xml
|
|
32
|
-
<universal-links>
|
|
33
|
-
<!-- this is dynamic link created in firebase -->
|
|
34
|
-
<host name="zm4e4.app.goo.gl" scheme="https" />
|
|
35
|
-
<!-- this is your firebase app link -->
|
|
36
|
-
<host name="routing-aadd4.firebaseapp.com" scheme="https">
|
|
37
|
-
<path url="/__/auth/callback" />
|
|
38
|
-
</host>
|
|
39
|
-
</universal-links>
|
|
40
|
-
<!-- for android -->
|
|
41
|
-
<preference name="AndroidLaunchMode" value="singleTask" />
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
*Make sure your `<widget id="com.yourandroid.id" ... >` the same with Android app's id you
|
|
45
|
-
added in Firebase.*
|
|
46
|
-
|
|
47
|
-
# Step 4: Add login code
|
|
48
|
-
In `login.service.ts` add this function:
|
|
49
|
-
```ts
|
|
50
|
-
|
|
51
|
-
import { AngularFireAuth } from '@angular/fire/compat/auth';
|
|
52
|
-
import firebase from 'firebase/app';
|
|
53
|
-
import AuthProvider = firebase.auth.AuthProvider;
|
|
54
|
-
|
|
55
|
-
export class AuthService {
|
|
56
|
-
private user: firebase.User;
|
|
57
|
-
constructor(public afAuth: AngularFireAuth) {
|
|
58
|
-
afAuth.authState.subscribe(user => {
|
|
59
|
-
this.user = user;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
signInWithFacebook() {
|
|
64
|
-
console.log('Sign in with Facebook');
|
|
65
|
-
return this.oauthSignIn(new firebase.auth.FacebookAuthProvider());
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
signInWithGoogle() {
|
|
69
|
-
console.log('Sign in with Google');
|
|
70
|
-
return this.oauthSignIn(new firebase.auth.GoogleAuthProvider());
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private oauthSignIn(provider: AuthProvider) {
|
|
74
|
-
if (!(<any>window).cordova) {
|
|
75
|
-
return this.afAuth.auth.signInWithPopup(provider);
|
|
76
|
-
} else {
|
|
77
|
-
return this.afAuth.auth.signInWithRedirect(provider)
|
|
78
|
-
.then(() => {
|
|
79
|
-
return this.afAuth.auth.getRedirectResult().then( result => {
|
|
80
|
-
// This gives you an Access Token. You can use it to access the associated APIs.
|
|
81
|
-
let token = result.credential.accessToken;
|
|
82
|
-
// The signed-in user info.
|
|
83
|
-
let user = result.user;
|
|
84
|
-
console.log(token, user);
|
|
85
|
-
}).catch(function(error) {
|
|
86
|
-
// Handle Errors here.
|
|
87
|
-
alert(error.message);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
# Common problems
|
|
96
|
-
|
|
97
|
-
If you get an error, when you build the code, that looks like this:
|
|
98
|
-
```
|
|
99
|
-
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'manifest' of undefined
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Please take a look at the fix from [this issue](https://github.com/nordnet/cordova-universal-links-plugin/issues/134):
|
|
103
|
-
> Making this change in 'cordova-universal-links-plugin/hooks/lib/android/manifestWriter.js' fixed this issue for me:
|
|
104
|
-
> [b2c5784#diff-d5955d9f4d88b42e5efd7a3385be79e9](https://github.com/nordnet/cordova-universal-links-plugin/commit/b2c5784764225319648e26aa5d3f42ede6d1b289#diff-d5955d9f4d88b42e5efd7a3385be79e9)
|
package/docs/ionic/cli.md
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
# Installation and Setup with Ionic CLI
|
|
2
|
-
|
|
3
|
-
### 0. Prerequisites
|
|
4
|
-
|
|
5
|
-
Before you start installing AngularFire, make sure you have latest version of Ionic cli installed.
|
|
6
|
-
To verify run the command `ionic -v` and check your version. The CLI should be at least version 3.0.0 or greater.
|
|
7
|
-
|
|
8
|
-
If not, you may need to do the following:
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
# if you have the wrong cli version only
|
|
12
|
-
npm uninstall -g ionic
|
|
13
|
-
npm cache clean
|
|
14
|
-
|
|
15
|
-
# reinstall clean version
|
|
16
|
-
npm install -g @ionic/cli
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### 1. Create a new project
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
ionic start <project-name>
|
|
23
|
-
cd <project-name>
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
The Ionic CLI's `start` command will prompt you to pick a starting template, and scaffold out the project for you.
|
|
27
|
-
|
|
28
|
-
### 2. Test your Setup
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
ionic serve
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Your default browser should start up and display a working Ionic app.
|
|
35
|
-
|
|
36
|
-
### 3. Install AngularFire 2 and Firebase
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npm install @angular/fire firebase --save
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Now that you have a new project setup, install AngularFire and Firebase from npm.
|
|
43
|
-
|
|
44
|
-
### 4. Add Firebase config to environments variable
|
|
45
|
-
|
|
46
|
-
Let's create a new file, `src/environment.ts` and start adding our Firebase config:
|
|
47
|
-
|
|
48
|
-
```ts
|
|
49
|
-
export const firebaseConfig = {
|
|
50
|
-
apiKey: '<your-key>',
|
|
51
|
-
authDomain: '<your-project-authdomain>',
|
|
52
|
-
databaseURL: '<your-database-URL>',
|
|
53
|
-
projectId: '<your-project-id>',
|
|
54
|
-
storageBucket: '<your-storage-bucket>',
|
|
55
|
-
messagingSenderId: '<your-messaging-sender-id>'
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
### 5. Setup @NgModule for the AngularFireModule
|
|
62
|
-
|
|
63
|
-
Open `/src/app/app.module.ts`, inject the Firebase providers, and specify your Firebase configuration.
|
|
64
|
-
This can be found in your project at [the Firebase Console](https://console.firebase.google.com):
|
|
65
|
-
|
|
66
|
-
```ts
|
|
67
|
-
import { BrowserModule } from '@angular/platform-browser';
|
|
68
|
-
import { NgModule } from '@angular/core';
|
|
69
|
-
import { IonicApp, IonicModule } from 'ionic-angular';
|
|
70
|
-
import { MyApp } from './app.component';
|
|
71
|
-
|
|
72
|
-
import { AngularFireModule } from '@angular/fire/compat';
|
|
73
|
-
import { firebaseConfig } from '../environment';
|
|
74
|
-
|
|
75
|
-
@NgModule({
|
|
76
|
-
declarations: [ MyApp ],
|
|
77
|
-
imports: [
|
|
78
|
-
BrowserModule,
|
|
79
|
-
IonicModule.forRoot(MyApp),
|
|
80
|
-
AngularFireModule.initializeApp(firebaseConfig)
|
|
81
|
-
],
|
|
82
|
-
bootstrap: [IonicApp],
|
|
83
|
-
})
|
|
84
|
-
export class AppModule {}
|
|
85
|
-
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
There will be more or less imports depending on your app. This is just an example setup.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
#### Custom FirebaseApp Names
|
|
92
|
-
You can optionally provide a custom FirebaseApp name with `initializeApp`.
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
@NgModule({
|
|
96
|
-
declarations: [ MyApp ],
|
|
97
|
-
imports: [
|
|
98
|
-
BrowserModule,
|
|
99
|
-
IonicModule.forRoot(MyApp),
|
|
100
|
-
AngularFireModule.initializeApp(firebaseConfig, 'my-app-name')
|
|
101
|
-
],
|
|
102
|
-
bootstrap: [IonicApp],
|
|
103
|
-
})
|
|
104
|
-
export class AppModule {}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### 6. Setup individual @NgModules
|
|
108
|
-
|
|
109
|
-
After adding the AngularFireModule you also need to add modules for the individual @NgModules that your application needs.
|
|
110
|
-
- AngularFireAuthModule
|
|
111
|
-
- AngularFireDatabaseModule
|
|
112
|
-
- AngularFireFunctionsModule
|
|
113
|
-
- AngularFirestoreModule
|
|
114
|
-
- AngularFireStorageModule
|
|
115
|
-
- AngularFireMessagingModule
|
|
116
|
-
|
|
117
|
-
#### Adding the Firebase Database and Auth Modules
|
|
118
|
-
|
|
119
|
-
For example if you application was using both Firebase authentication and the Firebase database you would add:
|
|
120
|
-
|
|
121
|
-
```ts
|
|
122
|
-
import { BrowserModule } from '@angular/platform-browser';
|
|
123
|
-
import { NgModule } from '@angular/core';
|
|
124
|
-
import { IonicApp, IonicModule } from 'ionic-angular';
|
|
125
|
-
import { MyApp } from './app.component';
|
|
126
|
-
|
|
127
|
-
import { AngularFireModule } from '@angular/fire/compat';
|
|
128
|
-
import { firebaseConfig } from '../environment';
|
|
129
|
-
import { AngularFireDatabaseModule } from '@angular/fire/compat/database';
|
|
130
|
-
import { AngularFireAuthModule } from '@angular/fire/compat/auth';
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
@NgModule({
|
|
134
|
-
declarations: [ MyApp ],
|
|
135
|
-
imports: [
|
|
136
|
-
BrowserModule,
|
|
137
|
-
IonicModule.forRoot(MyApp),
|
|
138
|
-
AngularFireModule.initializeApp(firebaseConfig), // imports firebase/app needed for everything
|
|
139
|
-
AngularFireDatabaseModule, // imports firebase/database, only needed for database features
|
|
140
|
-
AngularFireAuthModule, // imports firebase/auth, only needed for auth features
|
|
141
|
-
],
|
|
142
|
-
bootstrap: [IonicApp],
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
### 7. Inject AngularFireDatabase
|
|
148
|
-
|
|
149
|
-
Open `/src/pages/home/home.ts`, and start to import `AngularFireDatabase` and `FirebaseListObservable`:
|
|
150
|
-
|
|
151
|
-
```ts
|
|
152
|
-
import { Component } from '@angular/core';
|
|
153
|
-
import { NavController } from 'ionic-angular';
|
|
154
|
-
import { AngularFireDatabase } from '@angular/fire/compat/database';
|
|
155
|
-
import { Observable } from 'rxjs/Observable';
|
|
156
|
-
|
|
157
|
-
@Component({
|
|
158
|
-
selector: 'page-home',
|
|
159
|
-
templateUrl: 'home.html'
|
|
160
|
-
})
|
|
161
|
-
export class HomePage {
|
|
162
|
-
items: Observable<any[]>;
|
|
163
|
-
constructor(
|
|
164
|
-
public db: AngularFireDatabase,
|
|
165
|
-
public navCtrl: NavController,
|
|
166
|
-
) {}
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### 8. Bind to a list
|
|
172
|
-
|
|
173
|
-
In `/src/pages/home/home.ts`:
|
|
174
|
-
|
|
175
|
-
```ts
|
|
176
|
-
import { Component } from '@angular/core';
|
|
177
|
-
import { NavController } from 'ionic-angular';
|
|
178
|
-
import { AngularFireDatabase } from '@angular/fire/compat/database';
|
|
179
|
-
import { Observable } from 'rxjs/Observable';
|
|
180
|
-
|
|
181
|
-
@Component({
|
|
182
|
-
selector: 'page-home',
|
|
183
|
-
templateUrl: 'home.html'
|
|
184
|
-
})
|
|
185
|
-
export class HomePage {
|
|
186
|
-
items: Observable<any[]>;
|
|
187
|
-
constructor(
|
|
188
|
-
public db: AngularFireDatabase,
|
|
189
|
-
public navCtrl: NavController,
|
|
190
|
-
) {
|
|
191
|
-
this.items = db.list('list').valueChanges();
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
Open `/src/pages/home/home.html`:
|
|
198
|
-
|
|
199
|
-
```html
|
|
200
|
-
<ion-header>
|
|
201
|
-
---
|
|
202
|
-
</ion-header>
|
|
203
|
-
|
|
204
|
-
<ion-content padding>
|
|
205
|
-
<ion-item *ngFor="let item of items | async">
|
|
206
|
-
{{item | json}}
|
|
207
|
-
</ion-item>
|
|
208
|
-
</ion-content>
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### 9. Run your app
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
ionic serve
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
That's it! If there's any issues, be sure to file an issue on the AngularFire repo or the Ionic repo, depending on who's to blame :smile:
|
|
218
|
-
|