Comments (10)
from pushy-flutter.
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.
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.
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.
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:
- Device manufacturer
- Device model name
- Android OS version
from pushy-flutter.
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.
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.
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.
from pushy-flutter.
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)
- Installing background listener fails in release mode HOT 9
- iOS app killed - Click on notification not open specific screen HOT 2
- iOS Push permission deined HOT 1
- A blank screen appears when app is killed and user taps on a notification HOT 2
- Web support HOT 1
- Dialog pop in IOS when app is in foreground. HOT 2
- Infinix Mobile Notification Issue HOT 1
- Crashes and Freezes Pushy.Register() on VIVO and OPPO devices . HOT 1
- Status Bar Notification Issue In Android HOT 3
- Feature: Support for Linux HOT 1
- Pushy.register get device token giving error HOT 1
- Token is not generating Pushy in IOS HOT 3
- Android , Pushy ( 7552): Notifications have been disabled by the app HOT 2
- Please, update dependencies HOT 4
- await Pushy.register() HOT 8
- Unable to send notification on deivce id in flutter HOT 1
- Support for Notification Channel on Android HOT 3
- [Feature Request] Field to know in which lifecycle the notification received HOT 1
- Registration failed: The application identifier is missing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pushy-flutter.