I have developed a chat app using Xamarin, and the app receives push notification when a new chat arrives. The push notifications are delivered through OneSignal platform which uses Firebase for Android and APNS for iOS.
I would like to unsubscribe for push notification from the device itself when a user logouts, so that even if the server sends one, it wont be displayed. I can achieve this in iOS with the following code.
UIApplication.SharedApplication.UnregisterForRemoteNotifications();
What would be the equivalent for this in Android. I have searched a lot in documentation but no luck. Appreciate some help. Even it someone can tell the code in Java or Kotlin, that would do.
In Android you must delete that instance Id to avoid receiving push notifications but also disable auto init so that it doesn't generate a new token registration:
FirebaseMessaging.Instance.AutoInitEnabled = false;
FirebaseInstanceId.Instance.DeleteInstanceId();
Related
I've implemented Firebase Push Notifications using Admin SDK for both android and iOS. In iOS i'm receiving notifications on all the stages (Foreground, background or even terminated), but in android I need to integrate Local Notifications again for receiving when app is in foreground. Even I'm successfully integrated it. I need to maintain single notification for particular user. I'm using TAG field while generating Push Notifications whereas in the frontend even i provide the same tag its generating a new notification. So I've added tag as notification_id by converting it to HASHCODE. Now I'm receiving unique notifications using Local Notifications as well.
My problem i'm facing is
For instance consider when my app is in foreground I've generated notification using Local Notifications Package. In the next minute I went to background so I've generated Notification using firebase SDK. In this case I'm seeing 2 Different Notifications for the Same User. One from Local and another from Firebase. In need to maintain single notification for particular user.Can anyone guide to how to solve this.
I want to stop my Android App opening automatically when I click on the PUSH Notification send via Google FCM. I have changed the message type from Data Message to Notification message.
The PUSH I am sending via the server REST API has a promo code in it, but has nothing to do with my App really, so I dont want the Android App to open at all. I can't used the FCM Console to send the PUSH notification as each promo code is unique to the user and their pet, and there are thousands of them. I'm using the test http v1. api but the actual Android App has been built by someone else and I dont have access to the source code. What should I be looking out for ? Is the PUSH auto opening the App due to a call it makes and an intent in the app I can't change?
Thanks for any guidance.
Using a serverless architecture built on AWS, I'm looking for the best way to have users receive near-instant notifications of new "chats" within my Android app. I don't necessarily want to see a push notification appear in the phone's notification tray - I just want the app to listen for new messages, and update the view accordingly.
Here's my thinking: every time a user sends a chat, I'd basically trigger a Lambda function which would call SNS or IoT to publish the notification to any subscribed users of this chat.
But since SNS / IoT both work by sending "push notifications" to the phone, does that mean the message would have to appear within the phone's notification tray? I'm just looking for a way for my app to silently receive near-instant notifications from AWS and execute code to update its view.
Some other notes:
1) I don't want to build this using a server / EC2 with websocket listeners - I'd rather go serverless.
2) I've looked in Google's Firebase real-time DB which looks very capable, but as the rest of my architecture is on AWS, I'd like to stay there if possible
If you are making app for Android only, you can make use of the data message in FCM from Firebase. You can handle the message in onMessageReceived no matter your apps is on Foreground or Background.
Apart from that, firebase provide integration with most server side language. You should be able to send the message in your lambda function.
my suggestion is using FireBase...
and make your Json tag with "data" than "Notification"
I have a very simple app made with android studio, an web viewer for my forum app. I integrated push notfications to be able to send notifications like "Hi! There are some new subjects on our forum, check it out" and make people open the app. I followed the exact documentation from here https://pushbots.com/developer/docs/android-sdk-integration
I am now able to send notifications to all the users that have my application. My problem is that they dont see the notification unless they have the application opened. For example, if I test it and send a push notification, but i dont have the app opened, i wont receive anything. I want to be able to send notifications even if they have the app closed, that's my point, i want to make them open the app to see the new questions on my forum
What should i do?
Make use of what was formerly known as Google Cloud Messaging and is now known as Firebase Cloud Messaging. Can push messages to user phone even when app is closed
What will an ideal android app notification server architecture. I am developing an android in ionic. It has a mqtt server that serve chat purpose.
What i want is when my app receive a new message it should show the message as native notification.
What I am confuse is as I already have mqtt server that can do real time messaging, do I really need to use google GCM for sending & receiving notification or I can serve my purpose with my existing configuration.
In my existing app I directly calling mqqt server from my android app for chatting purpose, so can it be same for notification also i.e. send a push notification directly from app just as a chat message.
Can anyone brief me about a push notification architecture implementation ?
Conceptually this should all work fine with just MQTT, no need for GCM.
The problem may be your use of cordova/ionic. It's been a long time since I looked at MQTT support in cordova, but to do push notifications properly you will need to run the MQTT client in a Android Service so it will stay running in the background and have it create notifications in response to received messages.
If the cordova MQTT support will not allow background services you will need to write your own extension.