Skip to content

feat(app-installations): web v9 SDK implementation #9007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import 'dart:async';
import 'package:firebase_core_web/firebase_core_web_interop.dart';
import 'package:js/js.dart';

import 'firebase_interop.dart' as firebase_interop;
import 'installations_interop.dart' as installations_interop;

export 'installations_interop.dart';

Installations getInstallationsInstance([App? app]) {
return Installations.getInstance(app != null
? firebase_interop.installations(app.jsObject)
: firebase_interop.installations());
? installations_interop.getInstallations(app.jsObject)
: installations_interop.getInstallations());
}

class Installations
Expand All @@ -32,12 +31,14 @@ class Installations
installations_interop.InstallationsJsImpl jsObject)
: super.fromJsObject(jsObject);

Future<void> delete() => handleThenable(jsObject.delete());
Future<void> delete() =>
handleThenable(installations_interop.deleteInstallations(jsObject));

Future<String> getId() => handleThenable(jsObject.getId());
Future<String> getId() =>
handleThenable(installations_interop.getId(jsObject));

Future<String> getToken([bool forceRefresh = false]) =>
handleThenable(jsObject.getToken(forceRefresh));
handleThenable(installations_interop.getToken(jsObject, forceRefresh));

Func0? _onIdChangedUnsubscribe;

Expand All @@ -51,7 +52,8 @@ class Installations

void startListen() {
assert(_onIdChangedUnsubscribe == null);
_onIdChangedUnsubscribe = jsObject.onIdChange(wrapper);
_onIdChangedUnsubscribe =
installations_interop.onIdChange(jsObject, wrapper);
}

void stopListen() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@JS('firebase.installations')
@JS('firebase_installations')
library firebase_interop.installations;

import 'package:firebase_core_web/firebase_core_web_interop.dart';
import 'package:js/js.dart';

@JS('Installations')
abstract class InstallationsJsImpl {
external AppJsImpl get app;
@JS()
external InstallationsJsImpl getInstallations([AppJsImpl? app]);

@JS()
external PromiseJsImpl<String> getId(InstallationsJsImpl installations);

external PromiseJsImpl<void> delete();
@JS()
external PromiseJsImpl<String> getToken(InstallationsJsImpl installations,
[bool? forceRefresh]);

external PromiseJsImpl<String> getId();
@JS()
external PromiseJsImpl<void> deleteInstallations(
InstallationsJsImpl installations);

external PromiseJsImpl<String> getToken([bool? forceRefresh]);
@JS()
external Func0 onIdChange(
InstallationsJsImpl installations, Func1<String, void> forceRefresh);

external Func0 onIdChange(Func1<String, void> observer);
@JS('Installations')
abstract class InstallationsJsImpl {
external AppJsImpl get app;
}