-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
firebase_app_installations.dart
64 lines (52 loc) 路 2.28 KB
/
firebase_app_installations.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
part of firebase_app_installations;
class FirebaseInstallations extends FirebasePluginPlatform {
FirebaseInstallations._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_app_installations');
// Cached and lazily loaded instance of [FirebaseAppInstallationsPlatform] to avoid
// creating a [MethodChannelFirebaseInstallations] when not needed or creating an
// instance with the default app before a user specifies an app.
FirebaseAppInstallationsPlatform? _delegatePackingProperty;
/// Returns the underlying [FirebaseFunctionsPlatform] delegate for this
/// [FirebaseFunctions] instance. This is useful for testing purposes only.
FirebaseAppInstallationsPlatform get _delegate {
return _delegatePackingProperty ??=
FirebaseAppInstallationsPlatform.instanceFor(app: app);
}
/// The [FirebaseApp] for this current [FirebaseInstallations] instance.
final FirebaseApp app;
static final Map<String, FirebaseInstallations> _cachedInstances = {};
/// Returns an instance using the default [FirebaseApp] and region.
static FirebaseInstallations get instance {
return FirebaseInstallations.instanceFor(
app: Firebase.app(),
);
}
/// Returns an instance using a specified [FirebaseApp].
static FirebaseInstallations instanceFor({required FirebaseApp app}) {
return _cachedInstances.putIfAbsent(app.name, () {
final instance = FirebaseInstallations._(app: app);
FirebasePluginPlatform.verify(instance);
return instance;
});
}
/// Deletes the Firebase Installation and all associated data.
Future<void> delete() {
return _delegate.delete();
}
/// Creates a Firebase Installation if there isn't one for the app and
/// returns the Installation ID.
Future<String> getId() {
return _delegate.getId();
}
/// Returns an Authentication Token for the current Firebase Installation.
Future<String> getToken([bool forceRefresh = false]) {
return _delegate.getToken(forceRefresh);
}
/// Sends a new event via a [Stream] whenever the Installation ID changes.
Stream<String> get onIdChange {
return _delegate.onIdChange;
}
}