Trigger.io reload channels do not have active users - reload

I am trying to test the Trigger.io reload function on my app, and have created a new stream but there are no active users for any of these channels.
Does code need to be added in the app to subscribe users to the reload streams?

Currently there is a 15 minute delay in the reported user numbers.
However, if you have just installed a version of your app on a test device or run it in the emulator, you will be able to Reload it immediately even if the number of users showing up against the stream is still 0.
You do need to use the forge.reload.switchStream method in the app to put the user in the right stream. Or you can use the 'default' stream that is already there to reload all users without needing to add any extra code in your app.

Related

How to use firebase realtime-database in offline mode in Flutter app?

I came across a wonderful feature of Firebase offline feature. I integrated that in my app just by writing one line of code in my main.dart file after initializing Firebase await FirebaseDatabase.instance.setPersistenceEnabled(true);
Question 1 :
I couldn't able to understand the database.keepSynced(true) function because without using this line of code, my app is persisting old as well as fetching new updated data, so what this exactly does ?
Question 2 :
How could I prevent the write operations when a user is offline, because I read that after setting persistence enabled, it makes a queues of write operations and update them when user gets online, so how could I stop this ?
Question 3 :
Is this persistence feature going to work in IOS device as well or need some permission settings first ?
Thanks
When you call FirebaseDatabase.instance.setPersistenceEnabled(true) you're allowing Firebase to create a local file on the device where it persists any data it's recently read, and all writes that are pending while the device is offline.
When you call keepSynced(true) on a node, you are telling the SDK to always keep that node synchronized. It essentially creates a onValue listener on the node without any handler code, so you're purely doing this to keep the data synchronized for when the device does go offline.
By combining keepSynced(true) with setPersistenceEnabled(true), you're specifying that you want the app to continue working when it's offline across restarts, and which data is needed for that.
If you call keepSynced(true) on the root of your database, you're telling the SDK to synchronize all data in the database to the disk cache. While this may initially be a quick way to get offline mode for your app working, it typically won't scale when you more people start using your app.
If you only want to allow write operations while the client has a connection to the database backend, you can register a local listener to the .info/connected node, which is a true value when there is a connection and false otherwise.
Note that Firebase doesn't require this, as it queues the pending writes and executes them when the connection is restored. In general, I'd recommend working with the system here instead of against it, and also trying to make your app work gracefully in the offline scenario. In many cases there is no need to disable functionality while the app is offline.
Offline disk persistence is available on Android and iOS, but not on web.

How to handle FCM subscribeToTopic and unsubscribeFromTopic with Flutter

I am developing an app for which I use firebase as the backend. I am using FCM to send notifications to my users, however, I am not yet grasping how to use subscribeToTopic and unsubscribeFromTopic.
My use case (which I do not know how to get it working):
After a user installs the app, he will be subscribed to the main topic of the app (I have this working). The user could then go to settings to unsubscribe from the main topic (I do not have this working).
The struggle:
All the different tutorials I find describe how to subscribe to a topic, they call subscribeToTopic('some topic') in initstate of the welcome screen. Is it required to do this everytime the app starts? What happens when the user calls unsubscribeFromTopic('some topic') and the next time they start the app subscribeToTopic('some topic') is called again in initstate?
My idea: first time the app is loaded I call subscribeToTopic('some topic') and never again. Then in the settings screen a user can unsubscribe (and subscribe). Does this work? What should I pay attention to?
Thanks in advance for helping!
You check if the app is launched for the first time by either using shared_preferences which stores this information locally or by storing a variable on Firestore that tells you if the user has logged in to the app before.
You subscribe to the topic if it's the first time and if it's not, you do not subscribe.
The first time you open the app show a welcome screen or something like that, where you ask the user to receive notifications or not (which is always more user friendly).
If the user continues you save this value in a local database like shared preferences or hive.
If the user subscribed you call the subscribe to topic method
If the user does not subscribe ofcourse you do nothing.
Then on the settingspage:
Show a switch which value is gathered from the local database you already defined.
When the user taps the value is stored, based on this value you subscribe or onsubscribe.
This is how I have done it in my app where I also use topics instead of tokens.

Chrome Extension + Firebase - Calling firebase.database() in background, content and popup scripts equal new connection for each?

In Chrome Extensions we have around 3 different scripts that may run at once, a persistent background page running on a browser window, a content script for a single website and finally the popup script when a user presses the extension button.
I need to connect to my firebase.database() instance in all of these. They all use the same firebase app and database. Does firebase know somehow from all these different scripts to open one connection or are they all creating new ones? This is concerning the simultaneous connection limit.

Web app fetching background geolocation using service worker and push notification

I am looking for a solution to fetch geolocation periodically (every 1 minute) on mobile browser. I did some research and came to know that fetching geolocation in background (when phone is locked or webapp not active) is impossible. In foreground it works ok.
I am making a web app where I fetch user location and send it to my server. All works ok, until the point where user locks his/her phone. I tried many things for workarounds:
setInterval to get geolocation, works fine in foreground but fails in background
converted my web app into Android using cordova, but same problem existed
used https://github.com/mauron85/cordova-plugin-background-geolocation this plugin for android
works good in both foreground and background
but the same plugin does not work in iPhone (I did not tested it, I searched in Google before moving ahead)
Its not good to release my app with just one platform (android) support, thus this workaround also failed for me.
I also considered using serviceworkers for my web app but it seems issue persist for background
https://github.com/w3c/ServiceWorker/issues/745
I have another solution in mind, but before investing time in it, I wish to know if someone has tried it already.
I learnt about Push notifications:
Web app client registers to Push notification
It sends
subscriber object to my server
My server using this object sends
message to Push notification server
Push notification server
sends messages to my web app client
My web app client wakes up my
service worker for a brief period to show the notification message
As per google documentation:
Note: In the current implementation
of Chrome, whenever we receive a push message and we don't have our
site visible in the browser we must display a notification. That is,
we can't do it silently without the user knowing. If we don't
display a notification the browser automatically creates one to let
the user know that the app is doing work in the background.
I won't mind showing a permanent notification to users until my app is running. I am ready for this trade-off.
Now, my question is, at step 5, when I wake up the service worker **is there a chance I call my main.js (main web app) which might be running in background **, will fetch the geolocation and update it to my server?
Has someone tried this solution already with success or failure, please inform.
Can you try Page visibility Api, which listens for visibilitychange of a browser tab is hidden or switched to other tab (in case of browser). For mobiles, it's just a try.
src : https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
or You can look into this answer too..
Detecting when screen is locked

How to get latest RMP data?

In Realm Browser and in my App I can watch how rows get deleted, modified and created when I log in with a Sync User, like it is getting synced slowly, when I login my app I would like to know when this sync ends, or better, get only the latest data at once and not the whole history of it.
I don't know if is a setting in Realm Object Server (Ubuntu) or in my App (iOS Swift)
Realm Mobile Platform syncs your data automatically in background, it allows you to work with the Realm url the same way you work with the local one.
So you can just use any type of Notifications to handle any data changes.

Resources