Skip to content
New issue

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

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

Already on GitHub? # to your account

Does the SDK support push notification by default? #200

Closed
tran-huy-phuc opened this issue Jun 17, 2019 · 5 comments
Closed

Does the SDK support push notification by default? #200

tran-huy-phuc opened this issue Jun 17, 2019 · 5 comments

Comments

@tran-huy-phuc
Copy link

I used parse SDK for Android and iOS before. The SDK saves the device tokens automatically (and silently) when parse is initialized on client app. Do we support this yet?

@phillwiggins
Copy link
Member

phillwiggins commented Jun 17, 2019 via email

@RodrigoSMarques
Copy link
Contributor

Hi @thphuc
I'm working on an app where I'm using Firebase Messaging.
I retrieve token for iOS / Android and use the ParseInstallation class to save in Parse and send Push.
Everything is working, except that there is an issue in Firebase that Push is not displayed if the app is closed.

@pastordee
Copy link
Contributor

The same here

@RodrigoSMarques
Copy link
Contributor

RodrigoSMarques commented Jun 18, 2019

I'm using the following code with Firebase Messaging e flutterLocalNotifications to show in the foreground

@override
  void initState() {
    // TODO: implement initState
    super.initState();

    configNotification();
  }

  void configNotification() {
    var android = new AndroidInitializationSettings('mipmap/ic_launcher');
    var ios = new IOSInitializationSettings();
    var platform = new InitializationSettings(android, ios);
    flutterLocalNotificationsPlugin.initialize(platform);

    _firebaseMessaging.configure(
      onMessage: (Map<String, dynamic> message) async {
        print("onMessage: $message");
        showNotification(message);
      },
      onLaunch: (Map<String, dynamic> message) async {
        print("onLaunch: $message");
      },
      onResume: (Map<String, dynamic> message) async {
        print("onResume: $message");
      },
    );

    _firebaseMessaging.requestNotificationPermissions(
        const IosNotificationSettings(sound: true, badge: true, alert: true));
    _firebaseMessaging.onIosSettingsRegistered
        .listen((IosNotificationSettings settings) {
      print("Settings registered: $settings");
    });

    _firebaseMessaging.getToken().then((String token) {
      assert(token != null);
      UserBloc _userBloc = UserBloc();
      _userBloc.updateInstallation(token);
    });
  }

  showNotification(Map<String, dynamic> msg) async {
    var data = jsonDecode(msg["data"]["data"]);

    var android = new AndroidNotificationDetails(
      'xxxxID',
      "xxxxxName",
      "xxxxDescription",
    );

    var iOS = new IOSNotificationDetails();
    var platform = new NotificationDetails(android, iOS);
    await flutterLocalNotificationsPlugin.show(
        0, "xxxxx", data["alert"], platform);
  }

@phillwiggins
Copy link
Member

There's not been much movement on this recently. Are we safe to close?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants