Upon clicking the notification, I want it to open the link in a separate browser. It doesn't matter if it launches the app or not. The final thing should be opening in a browser.
A detailed guide of code and procedures would be really helpful.
Any alternative idea would also be helpful.
AskFirebase
You cannot pass links or text directly from firebase console when app is in background . You need to use Advanced Rest Client which is available in Chrome extensions.
Here is an example what code you need to write in Advanced Rest Client
{ "data": {
"message": "Yee",
"image" : "url.jpg",
"sound": "default",
"linkk": "https://stackoverflow.com/questions/57335468/how-can-i-use-fcm-to-send-links-to-an-android-app"
},
"to" : "/topics/test"
}
In this example those who subscribed to topic test will receive this message and will be able to open link in your app.
But!!!!
You should try when your app is in foreground the link will work fine even when you send notification from firebase console.
Related
I am working on an ionic application and need to implement push notifications using the back end API's developed in .NET.
While going through few blogs I found fire base API's and was able to complete a POC using Firebase. However the notification did not show when the app was in foreground.
I am not sure how to consume .NET API's to get the push messages. Can we achieve this without using Firebase. Please suggest. Thanks !
It is normal so that notification not show on forground using firebase notifications.
this.firebase.onNotificationOpen().subscribe( (msg) => {
if (this.platform.is('ios')) {
this.presentToast(msg.aps.alert);
//here notfication in ios
} else {
this.presentToast(msg.body);
//here notfication in android
}
});
This will trigger a toast of notification in foreground. If you want it as notfication, use local notfication and set the msg.body details as it should be shown inside the local notfication.
And as an advice, use onesignal notfication since it contains better features plus easier and more flexible.
i have an android app and i want to send a firebase data message to inform the users of a new app version available in the play store. I am sending a data message in order to reach devices in which the app is in background.
I want send the message to specific versions, or if it's possible to all versions except the last version.
What is the best way to do it? Can I specify a version number in a fcm data message?
Below is the data message i am sending.
Thanks in advance.
{
"to": "/topics/all",
"data": {
"title": "new version",
"body": "a new version is available in play store"
}
}
I don't have answer for your question but I can suggest another way to achieve your case.
Take a look at Firebase Remote Config.
You can define variable for your client to get anytime it start.
So for your case, we have 3 variable:
destinationVersion for your specific version
title
message
In the app, just put the logic like if app's version equal to destinationVersion , create a notification with title and message to tell user update the app
. Hope it helpful to you.
You can force users to update with Google now: https://developer.android.com/guide/playcore/in-app-updates#immediate
I was asked to develop a sample app integrated with Amazon Pinpoint. Since I am not a pro at developing apps, I decided to follow this simple tutorial and develop the app following the steps described in it. The only differences are that, instead of using an emulator, I executed the project in my own cell phone (a Xiaomi Redmi 4x) and instead of GCM, I used Firebase.
At first, it seemed to work perfectly, but when I moved the app to the background and went back to my homescreen, I could no more receive push notifications from my app. When the app is open and running, everytime I send a push notification a pop-up appears with Title "New Notification" and buttons "Ignore"/"View". But when in background, nothing is visible in my system tray!
Also, if someone knows which part of the code is responsible for this notifications, just warn me and I upload it here.
Okay, so after some tests I made it work (not through console, but through CLI). To do so, I followed some steps I found this question, that took me to two other documents: one from Amazon teaching how to send push notifications through CLI and a simple but very detailed tutorial of phonegap-plugin, the plugin used in our Ionic application to process the pushes.
First of all, replace the phonegap-plugin in your app with the master version avaliable in the github link I sent you.
Then, putting all those information together, I figured out how to write a .json file containing the information we need to send the pushes. Here is a sample of the code I used:
{
"MessageRequest": {
"Addresses": {
"YOUR_DEVICE_ADDRESS_HERE": {
"ChannelType": "GCM"
}
},
"MessageConfiguration": {
"GCMMessage": {
"RawContent": "{\"data\":{\"title\":\"StackOverflow rocks!\",\"body\":\"Am I right?\",\"actions\":[ { \"title\":\"Yes!\", \"callback\":\"app.yes\", \"foreground\":true }, { \"title\":\"No!\", \"callback\":\"app.no\", \"foreground\":false }]}}"
}
}
}
}
As you can see, to change the content in the push notificationm, you'll have to edit it's "RawContent". To do so, use the phonegap-plugin tutorial I sent you and find out how to do the alterations you wish.
Last step: once you updated your plugin version AND saved the code above in a .json file (let's call it test.json), you can send it to your phone oppening command line in the folder containing your .json and writting:
aws pinpoint send-messages --color on --region YOUR_SERVICE_REGION --cli-input-json file:///test.json
This should do the trick! Hope it works for you. If any doubts, just let me know!
We have built a smart bulb which we want to control using the Google Assistant as well(apart from our Android and iOS apps). I searched for this and figured out that we need to implement Google Weave protocol on our bulbs for it to be controllable via Google Assistant.
What I don't understand is how can I add this to Home app so that users can add it as smart bulb to Home app and control via Google Assistant?
You can make the link between home and your system via api.ai
The key concepts are here. This site creates JSON files which are loaded into the Google Actions API. Once approved you have a keyword or phrase which when said into Google home opens interactions with your system via webhooks.
For anyone facing the same problem, found my answer here: https://developers.google.com/actions/smarthome/
At the time I posted my question, this page either did not exist or I did not find it.
This page points to sample implementation for smart home device. Here is the link to github repo: https://github.com/actions-on-google/actionssdk-smart-home-nodejs It also has detailed instructions on how to run the code.
To summarize, we need provide following actions.json(which points to our server which fulfills 3 intents SYNC, QUERY and EXECUTE) file as our Action Package.
{
"actions": [{
"name": "actions.devices",
"deviceControl": {
},
"fulfillment": {
"conversationName": "automation"
}
}],
"conversations": {
"automation" :
{
"name": "automation",
"url": "https://<our server which provides fulfillment for SYNC, QUERY and EXECURE intents>"
}
}
}
I am writing a iOS and Android application that is supposed to notify users through the FCM API yet there seems to be a catch-22 within the firebase API that involves both platforms:
On Android, to handle new notifications using a custom implementation of FirebaseMessagingService.onMessageReceived(), one must create a DATA only message server-side. E.g: { "data": {"param": "foo" },"to" : "/topics/bar"}. The moment a "notification" field is included in the json, the custom implementation will not be called when the app is in the background. This would be ok but...
On iOS, if the "notification" field is not included in the message, the message just isn't received when the app is in the background which is unacceptable.
Thus, to receive background notification on iOS, you need to add the "notification" field, but adding this field makes the Android apps display bogus, non-customizable notifications when in the background!
I hope there is something that I am missing in the documentation. I would like to know how others have overcome this problem and whether it would be wise to stick with FCM for iOS or ditch it for something else.