Firebase Messaging with more than one sender id - flutter

According to the documentation it should be possible to receive messages from multiple senders, but I have not been able to accomplish this.
To enable this feature, make sure you have each sender's sender ID. When requesting registration, the client app fetches the token multiple times, each time with a different sender ID in audience field, using the token retrieval method for the given platform
This was indeed possible some time ago, by specifying the sender(s) id(s) when getting the token, but it was deprecated and the current getToken() method does not accept a senderId parameter any longer.
I also tried configuring multiple projects in the app, but Firebase Messaging does not seem to support instantiating with a different project name (while Firestore, Database, etc. do).
So my question here, in the current scenario, is how am I supposed to accomplish the reception of messages from different senders. After the deprecation of the senderId parameter in getToken(), is there an official approach to this that I'm unaware of?
Alternatively, is there any other approach you would recommend?
Note: I'm working with Flutter, but according to the documentation the same limitations are valid for native Android (and iOS?)

Related

Implementing visitor counter in flutter for web

I'm trying to implement a visitor-counter on a website built entirely with flutter-web and I'm trying to accomplish this with nothing but plain dart code and some packages from pub.dev.
But the problem which has been bugging me is that I need to find a way to uniquely identify users based on their browsers or their devices so that I don't end up incrementing the counter for the same person again and again upon a revisit.
So far what I've thought is that I could use firestore for keeping track of the total number of visitors and display the same on the webpage upon startup and use some caching package like dcache or localstorage (like described here) to keep track of users who are re-visiting the same webpage.
Is there any better approach to this problem? Any help would be appreciated 😁
(ps: I have no prior web dev experience)
Since you talk about users, I immediately think of using Firebase Authentication.
There are two ways you could use that here:
With anonymous authentication, you could create a unique ID for each user without requiring them to enter credentials.
If you want to be able to identify the same user on different browsers/devices, they will have to sign in with one of the supported providers (email/password, phone number, email link, facebook, google, etc).
No matter which one you choose, each user will now have a unique ID (called UID in Firebase terms), which you can use to identify them in the database. For example, you could create a document for each user in the database with their UID as the ID of that document. That way you're guaranteed that each user will have no more than a single document.
You'll still need to count the documents, for which I recommend checking out the distributed counter extension.
Also consider if you want to use the Firebase Realtime Database instead of Firestore here, as it might give you a simpler pricing model, and has a built-in presence system. You'd still use Firebase Authentication as before, but just swap the database.
There is a short way instead if you just want to capture number of visitors on your webapp.
I created a collection called "Visits" in firestore and generated auto id inside which I added a field called "count". That's it!
Now you just have to call this method in your first screen's init method :
updateCounter() async {
final cRef = FirebaseFirestore.instance.collection('VISITS');
await cRef
.doc("mS9fCXjvkpREt8LvanSb") //Paste the id which was generated automatically
.set({"count": FieldValue.increment(1)}, SetOptions(merge: true));
}

Xcode swift calendar event request between two Firebase users

I am currently building a messaging app using Firebase database. I was wondering if it is possible to send calendar event requests between two Firebase users.
So for example, the sender sends an event request to another user, and if the user accepts the request then that event is stored in both the sender and other users calendar.
Is this possible, possibly using eventkit?
Thanks
Yes, this is very possible, but completely up to you how you want to implement it.
I would first recommend a firebase function to tackle uploads (below) and then you can very easily send a notification to the other device using the same technique you would for a message.
You uploads could be done any number of ways. I think it is probably best to just mirror the behavior of a messaging app. For example, you have a node/document where you are savings the eventkit data. Upon writing to that node/document, your cloud function is triggered that notifies the receiving device.
I can provide more if necessary, but I would strongly suggest any tutorials about a firebase messaging/chat app but instead of writing a "message/text," you are writing your eventkit data.

Custom Notification Depending on action

SWIFT 3 / Firebase
app like instagram/Facebook
Notifications
I am working on letting users know when another user e.g. liked their post, made a friend request etc.
I set up everything for cloud messaging with firebase and can send bulk messages at all my devices.
Now I want to introduce notifications which contain the current user, the user who did the action and what happened.
Unfortunately I did not find anything about this despite the general implementing of firebase cloud messaging.
My questions are:
1: Do i have to structure a database (e.g. .child("notifications").child(userId).... ?
2: How do I get the token from the stranger user I address with the notification?
3: How can I make the input variable?
I am happy about all kinds of help!

Inconsistent notifications watching files with Google Drive REST API V3

I'm using this endpoint to subscribe for changes on a file: https://developers.google.com/drive/v3/reference/files/watch. While I'm receiving callbacks, some notifications don't happen right away and others seem to be dropped completely. I'm trying to figure out whether this is an issue with the service or something I'm not understanding about the API.
I've tried testing our setup with several different types of files and have gotten similar results with inconsistent notifications.
Wonder if anyone has done tests or has insider information about the reliability of change notifications? Is it around 99% or more like 50%? What is the expected distribution of delays? (it's definitely not instantaneous)
Without knowing what you have already done, I can only suggest that you check Push Notifications and see if you've missed some of the important things.
It was discussed that, to use push notifications, you need to do three things:
Register the domain of your receiving URL.
Set up your receiving URL, or "Webhook" callback receiver.
Set up a notification channel for each resource endpoint you want to watch.
In addition to that, note that there are required properties when making watch requests:
An id property string that uniquely identifies this new notification channel within your project. We recommend that you use a universally unique identifier (UUID) or any similar unique string.
A type property string set to the value web_hook.
An address property string set to the URL that listens and responds to notifications for this notification channel. This is your Webhook callback URL, and it must use HTTPS.
Also, Drive API will be able to send notifications to this HTTPS address only if there is a valid SSL certificate installed on your web server. Invalid certificates include:
Self-signed certificates.
Certificates signed by an untrusted source.
Certificates that have been revoked.
Certificates that have a subject that doesn't match the target hostname.
Hope that helps.

iphone app - preventing spam

I've developed an app that allows users to upload some photos and share them on Facebook/Dropbox/Twitter etc. Recently it went live in the app store.
However, I'm having a problem now: a bot is creating accounts and uploading many photos on my server. I've temporarily disabled the app, but now I'm looking for an efficient way to prevent this bot from doing this.
The bot's ip address is changing very often so it's impossible to block the ip. He creates accounts with a very realistic name and email address so it's hard to find out which users are real and which are created by the bot.
I was thinking of using a captcha, but I'm not sure if my app will be rejected by Apple if I implement this. I'm preferably looking for a way so I can prevent him from doing his work and so I don't have to resend the app to Apple again.
Could anyone give me some advice on what I could possibly do?
Thanks!
This is how I solved a similar problem:
I implemented a token-generator, which generates a one-time token for every single data transfer with the server, so even one for login-data, sending a file etc. This token is generated by a secret algorithm and can be verified server side, since you know how you generate one.
After one token is used, put it in a temporary list for the next X minutes/hours/days (depending on how many data transfers your server can handle). When a user tries to send data with a used token (i.e. the token matches one in the "banned" list), you can be sure that someone's trying to spam you -> mark the account as "spammer" and decide what you wish to do.
The algorithm must produce a different token each time (the best way would be a one-way hash), but you have to assure specific "properties", with which you can proof its authenticity.
So one very simple example:
Your algorithm in the client is generating a number between 1000000000000000000000 and 99999999999999999999999, this number is then multiplied with 12456564 and incremented by 20349.
The server becomes a specific command and data, and the generated token. Now it checks, whether (number - 20349)%12456564 is 0. If it's 0, it was likely generated by your "secret" algorithm.
It's a very basic example but you get the idea…