Firebase FCM fcm_options.link doesn't work - firebase

I'm using multicast to send the message to multiple users like this:
let webAppMessage = {
priority:'high',
notification:{title: titleNotif , body: `${name}: ${message}`, image: 'https://i.imgur.com/L6plOZO.png'},
tokens: webTokens,
webpush: {
fcm_options: {
link: "https://dummy.com"
}
}
admin.messaging().sendMulticast(webAppMessage)
However, clicking on the notification doesn't direct to the link.
I'm using firebase 8.6.3. I checked the other posts, but they don't resolve my issue. Is this because I'm using multicast to send the message? I can't find anything on the documentation about that.

This post solved it for me:
Firebase push notifications click does not work
Just use relative links... unlike what their documentation claims

Related

Firebase & Flutter (on Android) - MessagingToken is null

I'm running into trouble with some of my app's subscribers. We recently introduced the ability to send out notifications to our users using FirebaseMessaging. I should also mention that the app is on Android only.
Here is a brief section of code that we are running
updateUser(Userx user) async {
var messagingToken = await FirebaseMessaging.instance.getToken();
var packageInfo = await PackageInfo.fromPlatform();
user.messagingToken = messagingToken!;
user.appVersion = packageInfo.version;
await Users.updateUser(user);
}
It turns out that the FirebaseMessaging.instance.getToken() sometimes returns null and I can't figure out why that would be the case. The documentation also doesn't say much.
Could this be device specific? Maybe a user-setting to not allow any in-app messages?
A potential workaround is of course to null-check the token and simply accept it being null but I would like to understand the reasons behind that.
I found one more method that could be helpful, but I'm unsure about it.
Call FirebaseMessaging.instance.isSupported() first and act based on the result.

In-App Billing Plugin for Xamarin AcknowledgePurchase is not working

I am using the In-App Billing Plugin for Xamarin and Windows to implement non-consumable in-app purchases.
I have an issue that the payments are refunded for Android devices because I didn't implement the Acknowledge purchase.
The documentation advises adding the code below, but I still get a refund within three days of an item has been purchased.
if(purchase.State == PurchaseState.Purchased)
{
if (DeviceInfo.Platform == DevicePlatform.Android)
{
await billing.AcknowledgePurchaseAsync(purchase.PurchaseToken);
}
//consume an item
}
You are not storing the result - change it to
BillingResult billingResult = await inAppBilling.BillingClient.AcknowledgePurchaseAsync(acknowledgePurchaseParams);
if (billingResult.ResponseCode == BillingResponseCode.Ok)
{
// whatever you need to do with the result
}
Note my code is not using the plugin. But you need to do the check to see what the billingResult.ResponseCode is to be able to debug it.
If you are doing this within a fragment then you will also need to do the same in your MainActvity's OnResume, as there maybe a delay before you get a BillingResponseCode.Ok. Read the Android docs about the reasons for the delay. https://android-developers.googleblog.com/2020/06/meet-google-play-billing-library.html
Also note that you should verify the PurchaseToken against your backend server before acknowledging the purchase.

Firebase Analytics preventing proper use of dynamic link

I'm running in trouble here with Firebase.
The code is in flutter, I am testing in iOS
It's all going well, but when I try to get the dynamic link sent from:
auth.sendSignInWithEmailLink(parameters);
I get a debug message:
[Firebase/Analytics][I-ACS023001] Deep Link does not contain valid required params. URL params: {
amv = 16;
apn = "com.myproject.app";
ibi = "com.myproject.app";
ifl = "https://myproject-com.firebaseapp.com/__/auth/action?apiKey=XXXXXXXXXXX&mode=signIn&oobCode=XXXXXX&continueUrl=https://myproject-com.firebaseapp.com/email123&lang=en";
link = "https://myproject-com.firebaseapp.com/__/auth/action?apiKey=XXXXXXX&mode=signIn&oobCode=XXXXXX&continueUrl=https://myproject-com.firebaseapp.com/email123&lang=en";
}
where I changed my project name to "myproject" and put XXX inplace of apiKey/oobcode
and then, when I try to get the dynamic link with my app
final PendingDynamicLinkData data = await FirebaseDynamicLinks.instance.getInitialLink();
data is null.
So I am guessing Firebase Analytics is processing it and "killing" the dynamic link before my app can parse it.
Anyone managed to go through this?
I found the problem.
It is not that Firebase Analytics was "consuming" and killing the deep link.
The thing is that in iOS still today there is a delay the link and the state cycle...
https://medium.com/#diegoveloper/flutter-firebase-dynamic-link-6f1b79278ce0
This link explains it, problem 2 in the blog post.
Solved. I can still use analytics in Firebase.
It is impossible to remove analytics btw, you can only disable it.

Is there a way to generate a push ID from the Console in the new Realtime Database?

I have a listing node in my Database and wanted to add data into it from the web console. I want to have a push ID as the key of the object. Something like this :
{
"listing": {
"4acd4g1OreMyo2FkW6DlQH7ZhvY2": {
"name": "abc",
"location": "xyz"
}
}
}
where '4acd4g1OreMyo2FkW6DlQH7ZhvY2' would be the auto generated push ID.
I know it can be done using the Android/iOS/JS SDKs (using the push method). But is this possible from the console?
No, the console doesn't support it currently. I've been using firebase for a while and I've never needed it :)
while firebase console doesn't support it officially, there is a service called mockaroo that can generate firebase random id. Make sure to pick firebase option in the format dropdown

Meteor raix:push: Only "Badges" instead of "Badges, Sounds, Banners" in Notifications settings

In the Notifications section in the Settings app, my app only has "Badges" listed under it where it should have "Badges, Sounds, Banners".
Due to this I don't get "notified" when a new notification comes in, i.e. no banner, no sound, no vibrations. The notification shows up in the notifications tray and on the lock screen and the badge number updates, but there are no alerts.
Any ideas how to fix this?
My config.push.json looks like this:
{
"apn": {

"passphrase": "passphrase",
"key": "PushChatKey.pem",
"cert": "PushChatCert.pem"
},
"production":false,

"badge": true,
"sound": true,
"alert": true,
"vibrate": true
}
And I send notifications like this:
`Push.send({
from: 'Test',
title: 'Hello',text: 'World',
badge: 4,
query: {},
sound: 'default'
});`
(Similar to iOS push notifications only showing badges. need sounds and banners too but using different framework.)
I was able to solve this using the Push.Configure({}) setup on both server and client.
Server code:
Push.Configure({
apn:{
passphrase:'password',
certData: Assets.getText('enter certificate pem file name'),
keyData: Assets.getText('enter key pem file name')
},
production: false //or true if production
});
Client code (including the alert:true is what did the trick for me):
Push.Configure({
badge:true,
sound:true,
alert:true
});

Resources