GithubHelp home page GithubHelp logo

Android Notification about pushy-flutter HOT 10 CLOSED

pushy avatar pushy commented on August 23, 2024
Android Notification

from pushy-flutter.

Comments (10)

rwaidKalka avatar rwaidKalka commented on August 23, 2024 1

from pushy-flutter.

bawahakim avatar bawahakim commented on August 23, 2024 1

For future readers, it seems I was able to setup the entry point as a static method in an arbitrary class, and background notification (app in terminated state) still works

class MyClass {
  @pragma('vm:entry-point')
  static void _backgroundNotificationListener(Map<String, dynamic> data) {
    ...
   }
  void init() {
      Pushy.listen();
      Pushy.setNotificationListener(_backgroundNotificationListener);
      ...
  }
}

Seems flutter documentation allows it, and the package awesome_notifications does it this way too
https://pub.dev/documentation/flutter_isolate/latest/

from pushy-flutter.

pushy avatar pushy commented on August 23, 2024

Hi @rwaidKalka,
Thanks for reaching out. We'd be glad to assist.

Please refer to the following article in our support center for help on this topic:
How can I send notifications to Android devices in Doze / power saving mode?

from pushy-flutter.

rwaidKalka avatar rwaidKalka commented on August 23, 2024

Thanks for your instructions i already did that one too i disabled the battery optimization and still the notification is not reached to us while the app is terminated
is there anything else i can try to solve this issue ?
i am using flutter framework for the app development and the ios doesn't have any issue only android has this issue.

from pushy-flutter.

pushy avatar pushy commented on August 23, 2024

Hi @rwaidKalka,
We'd be glad to help you investigate this issue further.

If you could please provide the following information about a device experiencing this issue, that would be great:

  1. Device manufacturer
  2. Device model name
  3. Android OS version

from pushy-flutter.

rwaidKalka avatar rwaidKalka commented on August 23, 2024

Thanks for your reply
actually we are facing this problem with all android devices its not specific for a model or one device.

from pushy-flutter.

pushy avatar pushy commented on August 23, 2024

Hi @rwaidKalka,
Can you please share your project's main.dart? You may also send it to us privately at [email protected].

from pushy-flutter.

rwaidKalka avatar rwaidKalka commented on August 23, 2024

Sure i am gonna send it right now but i did the configuration in another file which is app.dart i will send both of them from the main.dart i called tha app.dart file in the runApp.

from pushy-flutter.

rwaidKalka avatar rwaidKalka commented on August 23, 2024

from pushy-flutter.

pushy avatar pushy commented on August 23, 2024

Hi @rwaidKalka,
Thanks for sending over your code.

You're experiencing this behavior because your backgroundNotificationListener is inside app.dart instead of being inside main.dart.

As per the Flutter docs, please ensure the following method is inside your main.dart file (remove it from app.dart), right after the import statements, and outside any Widget class declaration, to process push notifications in the background via a Flutter background isolate:

// Please place this code in main.dart,
// After the import statements, and outside any Widget class (top-level)

@pragma('vm:entry-point')
void backgroundNotificationListener(Map<String, dynamic> data) {
    // Print notification payload data
    print('Received notification: $data');

    // Notification title
    String notificationTitle = 'MyApp';

    // Attempt to extract the "message" property from the payload: {"message":"Hello World!"}
    String notificationText = data['message'] ?? 'Hello World!';

    // Android: Displays a system notification
    // iOS: Displays an alert dialog
    Pushy.notify(notificationTitle, notificationText, data);

    // Clear iOS app badge number
    Pushy.clearBadge();
}

from pushy-flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.