Skip to content

Firebase Push notification Problem #18192

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

Closed
ghost opened this issue Jun 5, 2018 · 19 comments
Closed

Firebase Push notification Problem #18192

ghost opened this issue Jun 5, 2018 · 19 comments
Labels
p: firebase Firebase plugins p: tooling Affects the flutter_plugin_tools package

Comments

@ghost
Copy link

ghost commented Jun 5, 2018

Scene1:
When i tried to send push notifications manually via Firebase coud Messaging console,it shows notifications without sound alert

Scene2:
When i disconnect my device then Restarted the "Run" in Adroid studio,its not receiving any Notifications, [I MUST HAVE TO Go to my Mobile settings>Notifications>selecting the app then toggle between Turn Off And Turn On the "Show Notifications"]

Scene3:
Even I have typed onresume(),onmessage(),onLaunch() functions,Its not showing notifications after closing the app

Scene4:
When i try to trigger Firebase Realtime Database,[When a entry is added or deleted i must receive notifications] its not working,But the code itself is deployed successfully??

Scene5:
Scheduled notifications are working fine with sound alerts too..but firebase notificationsare not working

Device: REDMI 4
IDE: VsCode ,Android Studio,

@zoechi
Copy link
Contributor

zoechi commented Jun 5, 2018

I think this needs more information.

  • output of flutter doctor
  • what is the content of the messages you sent?
  • did you follow all the steps in the plugin README.md?

I think for sound notification: {sound: 'default', ... is required.
For notifications to be received when the app is not running data: { click_action: 'FLUTTER_NOTIFICATION_CLICK', ... needs to be added.

@chinmaygarde chinmaygarde added p: firebase Firebase plugins p: first party p: tooling Affects the flutter_plugin_tools package labels Jun 9, 2018
@ghost
Copy link
Author

ghost commented Jun 11, 2018

@zoechi the sound issue is fixed by adding ur line.
Now the only issue is,when the app is minimized it shows notification,when the app is opened and i'm viewing the app its not showing notifications.

So I created a testing app with schedule notification library example,it shows notification even the app is opened and minimized,theres no issues.

then i decided to Add this shcedule notification project's .dart file as a new page
on my Existing project,but this time the schedule ntofication is also not showing anything

@zoechi
Copy link
Contributor

zoechi commented Jun 11, 2018

I haven't tried one of the schedule notification packages myself yet,
but that you need such a package (or run your own implementation) to show notifications when the app is in foreground is working as intended as far as I know.

@ghost
Copy link
Author

ghost commented Jun 14, 2018

@zoechi this is my code, today also it worked fine when app is minimized,but not when app is opened or closed

Is there any mistakes:

My Flutter code:

  import 'package:flutter/material.dart';
  import 'package:firebase_messaging/firebase_messaging.dart';
  import 'package:firebase_database/firebase_database.dart';

  void main() => runApp(new MyApp());

  class MyApp extends StatefulWidget {
    @override
    _MyAppState createState() => _MyAppState();
  }

  class _MyAppState extends State<MyApp> {
    String textValue = 'Hello World !';
    FirebaseMessaging firebaseMessaging = new FirebaseMessaging();

    @override

    void initState() {

    firebaseMessaging.configure(onLaunch: (Map<String, dynamic> msg) {
      print(" onLaunch called");
    }, onResume: (Map<String, dynamic> msg) {
      print(" onResume called");
    }, onMessage: (Map<String, dynamic> msg) {
      print(" onMessage called");
    });


    firebaseMessaging.requestNotificationPermissions(
     const IosNotificationSettings(sound: true, alert: true, badge: true));
    firebaseMessaging.onIosSettingsRegistered
    .listen((IosNotificationSettings setting) {
      print('IOS Setting Registed');
    });
    firebaseMessaging.getToken().then((token) {
      update(token);
    });
  }

My firebase code:

  const functions = require('firebase-functions');
  const admin = require('firebase-admin');
  admin.initializeApp(functions.config().firbase);
  exports.Novamachineries = functions.database.ref('items/{id}').onWrite(evt =>    
    {
      const payload = {
      notification: { title: 'New Customer Requested', body: 'Touch to Open The     
      App', badge: '1', sound: 'default', }
    };

    /////////////////////////////////////////////////////////////////////
    const token =   "abcdefghijklmnopqrstuvwxyz";   
    //i know token will varry ,
    so when the app is st1 timme opened it will write that token in firebase ,
    i will note that tokken then i'll write that code in this Firebase code,
    then i'll deploy it[it works fine too]
    /////////////////////////////////////////////////////////////////////
    if (token) {
        console.log('Toke is availabel .');

        return admin.messaging().sendToDevice(token, payload);
    } else {
        console.log('token error');
    }
  });

Only shows when app is minimized,Whats the error in my App code

@zoechi zoechi changed the title Firebase Push ntoification Problem Firebase Push notification Problem Jun 14, 2018
@zoechi
Copy link
Contributor

zoechi commented Jun 14, 2018

@ghost
Copy link
Author

ghost commented Jun 14, 2018

@zoechi its me, the same person brother

@ebeem
Copy link
Contributor

ebeem commented Jul 31, 2018

on app open, the callback onMessage is called

    }, onMessage: (Map<String, dynamic> msg) {
      print(" onMessage called");
    });

u should display the notification instead of printing here

@zoechi
Copy link
Contributor

zoechi commented Jul 31, 2018

@rajeshjeshar can this issue be closed?

@zoechi zoechi added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 31, 2018
@ghost
Copy link
Author

ghost commented Jul 31, 2018

@zoechi yes this can be closed and notifications are working 100%,now i'm writing a medium post on the way so it can be closed now thanks

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 31, 2018
@zoechi
Copy link
Contributor

zoechi commented Jul 31, 2018

Thanks for the update.
Please post the link when the article becomes available.

@zoechi zoechi closed this as completed Jul 31, 2018
@ghost
Copy link
Author

ghost commented Jul 31, 2018

@zoechi here is the post in medium thanks>>
https://medium.com/@rajeshjr/flutter-firestore-push-notification-on-data-change-youtube-style-subscribing-notifications-one-to-b09654db19e0

@alvinotienokelly
Copy link

when i try to onBackgroundMessage its says unknown paramter

@ghost
Copy link
Author

ghost commented Oct 4, 2019

when i try to onBackgroundMessage its says unknown paramter

There is no onBackgroundMessage inf Firebase messagiung Plugin.Hope you are asking about the OnLaunch() OnResume() methods ??

@alvinotienokelly
Copy link

when i try to onBackgroundMessage its says unknown paramter

There is no onBackgroundMessage inf Firebase messagiung Plugin.Hope you are asking about the OnLaunch() OnResume() methods ??

I think there is in the new flutter_messaging plugin version

@ghost
Copy link
Author

ghost commented Oct 13, 2019

when i try to onBackgroundMessage its says unknown paramter

There is no onBackgroundMessage inf Firebase messagiung Plugin.Hope you are asking about the OnLaunch() OnResume() methods ??

I think there is in the new flutter_messaging plugin version

Yeah! sorry Just now i've seen that change Log.

@kroikie
Copy link

kroikie commented Oct 13, 2019

@rajeshjeshar

This issue has been moved to firebase/flutterfire#809. Any further collaboration will be done there.

a-siva added a commit to a-siva/flutter that referenced this issue May 8, 2020
7e205b3 Roll src/fuchsia/sdk/mac from 1MVsE... to 4MCVP... (flutter#18217)
9193d8f Roll src/third_party/skia 0dc207f836da..a14084ba1b41 (3 commits) (flutter#18219)
403931f Add FlValue (flutter#18185)
46a6d96 [SkParagraph] Copy text height behavior to the Skia paragraph style (flutter#18178)
e7ee47d [web] Implement matrix parameter for linear gradient (flutter#18208)
28d9985 Reland again "Remove layer integral offset snapping flutter#17112" (flutter#18160)
5e361f5 Roll src/third_party/skia c66cd987f7c0..0dc207f836da (5 commits) (flutter#18212)
716dbf0 Refactor GLFW embedding to support headless mode (flutter#18205)
23cca32 Manual Roll of Dart 39e0e75fcf...ce62ad2e8b (flutter#18211)
15f72b8 Support EventChannel C++ plugin API for Linux/Windows (flutter#17015)
e5a7ca5 Handle leak of message handle when no engine present (flutter#18157)
d3bde19 add docs to platformviewios (and some drive-by changes) (flutter#17593)
b582d77 Roll src/third_party/skia 0066adefa97d..c66cd987f7c0 (4 commits) (flutter#18206)
5e7d6d0 Roll src/third_party/skia edea19858ccc..0066adefa97d (3 commits) (flutter#18203)
88b9d42 Remove the global engine entry timestamp (flutter#18182)
0dffdd5 Roll src/third_party/dart e86e4d61834a..ce62ad2e8b40 (13 commits) (flutter#18201)
56fe6d2 Roll src/third_party/skia 2871ab0727bf..edea19858ccc (3 commits) (flutter#18198)
bcdf991 Fixed ChildSceneLayer elevation issue on Fuchsia. (flutter#18144)
ede658e [profiling] CPU Profiling support for iOS (flutter#18087)
d043923 Roll src/third_party/skia e3d1de7c5281..2871ab0727bf (1 commits) (flutter#18197)
807f191 Roll src/third_party/dart 733153eb517c..e86e4d61834a (6 commits) (flutter#18195)
fe3f8df Roll src/third_party/skia 3b2db26c59d6..e3d1de7c5281 (4 commits) (flutter#18192)
34b0629 Roll fuchsia/sdk/core/mac-amd64 from jMJqf... to 1MVsE... (flutter#18194)
e9b2afe Roll fuchsia/sdk/core/linux-amd64 from RpHTv... to MhpFP... (flutter#18191)
35fa006 Roll src/third_party/skia 88d04cb51acf..3b2db26c59d6 (1 commits) (flutter#18190)
e54bb9e Roll src/third_party/dart 4da5b40fb6dc..733153eb517c (23 commits) (flutter#18188)
a-siva added a commit to a-siva/flutter that referenced this issue May 8, 2020
7e205b3 Roll src/fuchsia/sdk/mac from 1MVsE... to 4MCVP... (flutter#18217)
9193d8f Roll src/third_party/skia 0dc207f836da..a14084ba1b41 (3 commits) (flutter#18219)
403931f Add FlValue (flutter#18185)
46a6d96 [SkParagraph] Copy text height behavior to the Skia paragraph style (flutter#18178)
e7ee47d [web] Implement matrix parameter for linear gradient (flutter#18208)
28d9985 Reland again "Remove layer integral offset snapping flutter#17112" (flutter#18160)
5e361f5 Roll src/third_party/skia c66cd987f7c0..0dc207f836da (5 commits) (flutter#18212)
716dbf0 Refactor GLFW embedding to support headless mode (flutter#18205)
23cca32 Manual Roll of Dart 39e0e75fcf...ce62ad2e8b (flutter#18211)
15f72b8 Support EventChannel C++ plugin API for Linux/Windows (flutter#17015)
e5a7ca5 Handle leak of message handle when no engine present (flutter#18157)
d3bde19 add docs to platformviewios (and some drive-by changes) (flutter#17593)
b582d77 Roll src/third_party/skia 0066adefa97d..c66cd987f7c0 (4 commits) (flutter#18206)
5e7d6d0 Roll src/third_party/skia edea19858ccc..0066adefa97d (3 commits) (flutter#18203)
88b9d42 Remove the global engine entry timestamp (flutter#18182)
0dffdd5 Roll src/third_party/dart e86e4d61834a..ce62ad2e8b40 (13 commits) (flutter#18201)
56fe6d2 Roll src/third_party/skia 2871ab0727bf..edea19858ccc (3 commits) (flutter#18198)
bcdf991 Fixed ChildSceneLayer elevation issue on Fuchsia. (flutter#18144)
ede658e [profiling] CPU Profiling support for iOS (flutter#18087)
d043923 Roll src/third_party/skia e3d1de7c5281..2871ab0727bf (1 commits) (flutter#18197)
807f191 Roll src/third_party/dart 733153eb517c..e86e4d61834a (6 commits) (flutter#18195)
fe3f8df Roll src/third_party/skia 3b2db26c59d6..e3d1de7c5281 (4 commits) (flutter#18192)
34b0629 Roll fuchsia/sdk/core/mac-amd64 from jMJqf... to 1MVsE... (flutter#18194)
e9b2afe Roll fuchsia/sdk/core/linux-amd64 from RpHTv... to MhpFP... (flutter#18191)
35fa006 Roll src/third_party/skia 88d04cb51acf..3b2db26c59d6 (1 commits) (flutter#18190)
e54bb9e Roll src/third_party/dart 4da5b40fb6dc..733153eb517c (23 commits) (flutter#18188)
a-siva added a commit that referenced this issue May 8, 2020
7e205b3 Roll src/fuchsia/sdk/mac from 1MVsE... to 4MCVP... (#18217)
9193d8f Roll src/third_party/skia 0dc207f836da..a14084ba1b41 (3 commits) (#18219)
403931f Add FlValue (#18185)
46a6d96 [SkParagraph] Copy text height behavior to the Skia paragraph style (#18178)
e7ee47d [web] Implement matrix parameter for linear gradient (#18208)
28d9985 Reland again "Remove layer integral offset snapping #17112" (#18160)
5e361f5 Roll src/third_party/skia c66cd987f7c0..0dc207f836da (5 commits) (#18212)
716dbf0 Refactor GLFW embedding to support headless mode (#18205)
23cca32 Manual Roll of Dart 39e0e75fcf...ce62ad2e8b (#18211)
15f72b8 Support EventChannel C++ plugin API for Linux/Windows (#17015)
e5a7ca5 Handle leak of message handle when no engine present (#18157)
d3bde19 add docs to platformviewios (and some drive-by changes) (#17593)
b582d77 Roll src/third_party/skia 0066adefa97d..c66cd987f7c0 (4 commits) (#18206)
5e7d6d0 Roll src/third_party/skia edea19858ccc..0066adefa97d (3 commits) (#18203)
88b9d42 Remove the global engine entry timestamp (#18182)
0dffdd5 Roll src/third_party/dart e86e4d61834a..ce62ad2e8b40 (13 commits) (#18201)
56fe6d2 Roll src/third_party/skia 2871ab0727bf..edea19858ccc (3 commits) (#18198)
bcdf991 Fixed ChildSceneLayer elevation issue on Fuchsia. (#18144)
ede658e [profiling] CPU Profiling support for iOS (#18087)
d043923 Roll src/third_party/skia e3d1de7c5281..2871ab0727bf (1 commits) (#18197)
807f191 Roll src/third_party/dart 733153eb517c..e86e4d61834a (6 commits) (#18195)
fe3f8df Roll src/third_party/skia 3b2db26c59d6..e3d1de7c5281 (4 commits) (#18192)
34b0629 Roll fuchsia/sdk/core/mac-amd64 from jMJqf... to 1MVsE... (#18194)
e9b2afe Roll fuchsia/sdk/core/linux-amd64 from RpHTv... to MhpFP... (#18191)
35fa006 Roll src/third_party/skia 88d04cb51acf..3b2db26c59d6 (1 commits) (#18190)
e54bb9e Roll src/third_party/dart 4da5b40fb6dc..733153eb517c (23 commits) (#18188)
@shikharvaish28
Copy link

const payload = {
                notification: {
                    title: 'You have a new trip to '+dropLocation,
                    body: 'You have a trip to '+ dropLocation+' at ' + tripTime + ' on '+ tripDate,
                    sound: 'default',
                }
            };

            captainFirebase.messaging().sendToDevice(_token.data().token, payload);

I am using this code but the sound in not there when the notification is delivered.

@viveknimkarde
Copy link

@shikharvaish28 did you find any solution yet ?

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p: firebase Firebase plugins p: tooling Affects the flutter_plugin_tools package
Projects
None yet
Development

No branches or pull requests

7 participants