-
Notifications
You must be signed in to change notification settings - Fork 223
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
[Bug]: Receive notification when app is closed/background. #618
Comments
I have the same error. Why isn't there an update? |
Switched to firebase messaging. |
After hours long, finally my app can received background notifications and enter the apps once clicking on the notifications bar ! Just don't copy all the code section here to your project https://documentation.onesignal.com/docs/service-extensions#android-notification-service-extension. You need only the code below to make your background notifications works in flutter. package com.companyName.applicationName;
import android.content.Context;
import com.onesignal.OSNotification;
import com.onesignal.OSNotificationReceivedEvent;
import com.onesignal.OneSignal.OSRemoteNotificationReceivedHandler;
@SuppressWarnings("unused")
public class NotificationServiceExtension implements OSRemoteNotificationReceivedHandler {
@Override
public void remoteNotificationReceived(Context context, OSNotificationReceivedEvent notificationReceivedEvent) {
OSNotification notification = notificationReceivedEvent.getNotification();
notificationReceivedEvent.complete(notification);
}
} Then in Manifest.xml add below meta data in application not activity tag. <application>
<activity/>
<meta-data
android:name="com.onesignal.NotificationServiceExtension"
android:value="com.companyName.applicationName.NotificationServiceExtension" />
</application> On |
how about the latest version v5.0.4? |
still same issue |
Facing the same issue in version of onesignal_flutter ^5.0.4. I was testing in a real device running Android 13. Since I'm killing(closing completely) the app my application stops receiving any push notifications. Can't find any samples or articles about that in official documentation or in examples. |
My problem is I am getting notification in background but on click event of notification I want to navigate to specific screen but everytime I click on the notification it navigate to home screen instead of specific screen. |
@caini1213 @yigtkaya The same link Android Notification Service Extension has been update for the 5.x.x SDK.
This should only be a problem if your app is "force stopped". How are you killing your app?
See OneSignal's Android App is Force Stopped documentation for more details on this. @GainUpTrading |
I have the same error. Why isn't there an update? |
What happened?
Followed instructions here and created a .java file in com.package.name now I have 2 files there MainActivity.java And NotificationServiceExtension.java
Steps to reproduce?
Use flutter 3.4.2 Follow instructions here https://documentation.onesignal.com/docs/service-extensions#android-notification-service-extension Run the app
What did you expect to happen?
Expected to successfully run the app and receive notification when app is in foreground or background.
OneSignal Flutter SDK version
3.4.2
Which platform(s) are affected?
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: