Skip to content
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

Is it possible to send push notifications while the app is not open? #89

Closed
daljit97 opened this issue Aug 26, 2018 · 7 comments
Closed

Comments

@daljit97
Copy link

So I would like to send a custom notification using Firebase (like for example an update in my app) so that when the user can click notification in order to open the app. With QtFirebase is this possible? Can an app receive notifications even when closed? Reading on the Firebase docs it seems possible, but I am not sure about QtFirebase.

@rmallah
Copy link

rmallah commented Aug 26, 2018 via email

@daljit97
Copy link
Author

when the app is in background.
@rmallah does that mean that a user can receive a notification even when the app is completely closed and not in the multitasking view (still open but in the background)?

@rmallah
Copy link

rmallah commented Aug 27, 2018 via email

@daljit97
Copy link
Author

@rmallah one last question before I close this issue, how I can set up a custom icon for notifications received when the app is closed?

@daljit97
Copy link
Author

Ok I figured that the way to set up a custom icons is exactly the same as on Android Java and modify the manifest file(for Oreo you also need to configure Notification Channels).

@larpon
Copy link
Owner

larpon commented Oct 2, 2018

@daljit97 I'm glad you finally got it working. Have you documented the process? If so you're more than welcome to leave it here for future users! (The custom icon part)

@daljit97
Copy link
Author

daljit97 commented Oct 23, 2018

@larpon sorry for the late reply. I mentioned my problem here on stackexchange Unable to change icon

The issue was that I was testing the application on Android 8.0 Oreo. From this version of Android, Google requires that application make use of Notification Channels and applications are required to create a default Notification Channel. So I added the following code to the main activity of my application in the onCreate method:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    // Create channel to show notifications.
    String channelId  = getString(R.string.default_notification_channel_id);
    String channelName = getString(R.string.default_notification_channel_name);
    NotificationManager notificationManager =
            getSystemService(NotificationManager.class);
    notificationManager.createNotificationChannel(new NotificationChannel(channelId,
            channelName, NotificationManager.IMPORTANCE_LOW));
}

Then added the default notification id in the manifest file:

<meta-data android:name="com.google.firebase.messaging.default_notification_channel_id" android:value="@string/default_notification_channel_id"/>

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

No branches or pull requests

3 participants