The logic of my project is that I have to send notifications from admin panel to users in web and mobile app at the same time! another meaning:
When the admin send a notification to John Doe I need John to receive the notification on website and mobile app at the same time!
Does FCM can do that ? or I have to send notifications for mobile app and do another thing for web to web which is admin to user on web??
FCM does not guarantee the timing of the receipt of messages. If you send two messages, they will very likely end up on the devices at about the same time, but there is no guarantee that they will. Also consider that one of the devices might not even be on at the time the message is sent - that message simply will not arrive until the device is turned on again.
But you can certainly write code to send as many messages as you need to as many devices as you want, and simply accept the results.
Yes, it's possible. That's the nice thing about Firebase services, so that you don't have to write entirely different code for the same functionality for each platform separately.
Related
I am coding a vue.js app using web pushes with Firebase Cloud Messaging and I wondered if it was possible to send a web push to a user and in case the user was offline, to somehow store it for later display when the user opens the app again. Is there a principled approach to this problem, i.e. managing web pushes when the end user is offline?
The reason I am asking this is that, so far, all the web push notifications I've committed to FCM server with tokens of offline clients (i.e. desktop browsers) went into oblivion. To be sure, FCM didn't try pushing the notification again when the clients went back online.
For this reason I am considering coding a self-made dispatcher to manage web push for offline clients, but I need to make sure my efforts are worth it.
updated: I am now able to display notifications sent to an offline client after coming back online using appropriate time_to_live values. However, only the latest notification is displayed. How is there any specific reason why?
FCM's default behavior is exactly like that. From the docs:
If the device is not connected to FCM, the message is stored until a connection is established (again respecting the collapse key rules). When a connection is established, FCM delivers all pending messages to the device.
I'm thinking to work on firebase notifications in the last few days but I want to some answers for this few questions:
Does Ionic2 support firebase notifications ?
Will notification show in the top of screen when my application closed or it should be work in the background ?
Is firebase notification sent on time or it may take long time ?
If I assumed Ionic 2 can send private notifications (to my device only), so can I send public notification for all application users ?
If the answer of all questions "yes", wish you give me any useful links that may help me (if you have a time)
In addition to Gabriel's answer:
The default behavior for notifications is for it to show on the top part of the screen. I haven't worked on Ionic before, but AFAIK, the behavior should compared to Android.
With that said, you should refer to the Handling Messages part of the FCM docs.
There are factors to consider that may affect the time it takes for the device to receive a message, but as FCM's behavior, it would try it's best to send the message, as soon as feasible (see my answer here).
Gonna itemize this further:
Specific device only - Yup. When sending the message, just specify the registration token(s) that should recieve that message.
All devices - Yup. You could use the Firebase Notifications Console. But if you intend to send the message by using the REST API, you have to make sure that the devices are subscribed accordingly to your custom global topic.
About the device-to-device Gabriel mentioned, I think it should be worded as server to specific device(s).
Yes it does, and it works fine with FCM (Firebase Cloud Messaging, aka GCM - Google Cloud Messaging). It supports subscribing to topics and device-to-device notification via HTTP client. The topics subscriptions and device-to-device both require FCM plugin.
Yes, they'll appear on top of your device screen as any push notification, you'll just need to code how it'll behave after receiving it, like execute something if the notification is tapped, or do something if it's received and the app is already open (foreground), it's all up to you.
It's sent on time, i've never had delay problems, the longer it took to send the notification and i receive in my device was 10 seconds. But as far as i know it "stores" your notification for 24 hours, so if the servers go down or something happen the notification has a life time of 24 hours to be sent.
You can, as said in first answer, subscribe your users to topics. Let's say you want a topic to sent message so all users can receive, you can have an all topic, or have one only for logged users, one only for users who bought products, you can even get all users tokens and send one by one, but it's much better having them subscribe to topics.
Topics notifications can be sent via the Firebase project console. Device-to-device is sent by your app code.
To send device-to-device you'll need a token, it's provided by the FCM plugin (link above) and you'll need to store this token somewhere, like in your user node on Firebase. I usualy use the user device ID provided by the Device plugin to have his token, since the user can have multiple devices and log in all then, this'll prevent token overriding.
I don't know good tutorials about configuring FCM with Firebase, if i find something i'll edit the question and add it for you, but stick to the ionic native link and the FCM plugin github page.
Hope this helps.
i'm trying to implement push notification for our Windows Phone apps. We have about 40, 50 games on Mobile Phones, each game we have about ~400.000 users on their device.
I read some tutorial about push notification for Windows Phone such as this (http://joashpereira.com/blog/2015/03/18/php-script-to-send-android-ios-and-windwos-phone-push-notification/), but there's a problem is that we can only send push notification to one device per request. If i use this method, our program will process very very slow.
It's not look like Android or IOS, where i can send notification to ~1000 devices per request. That's pretty easier.
Anyone know how i can deal with this problem? Pls Help, thanks.
[Answer to a comment in the question]
The send method of the NotificationHub returns a NotificationOutcome object. This object contains several informations. Also a TrackingId which is a unique identifier which has been generated by the Notification Hub. But at the moment you have no possibility (as far as I know) to get more informations.
You can use the TrackingId to contact the azure-support, when you have problems or questions.
The problem is, that azure don't send the notifications directly to the devices. Azure just sends it to the device specific notification server (APNS, GCM, MPNS), and this server decide about the time to send the notificaiton
Look at this page at the end (section 'Debug failed notifications/ Review notification outcome' or 'Review telemetry') for more informations.
The idea of using the push notifications is only to have a notification mechanism that will send a notification when there is a new message waiting to download from the backend service: all the notifications are of the same type e.g. "refresh messages from the server" (the same for Android and iOS).
Are there any limits for the Apple/Google push notifications services?
Assuming that my application will handle more that 100k active users (or even 1M or more users) - would there be any problem with the Apple Push Notifications or GCM services?
If using the push notifications for such a service is not a good idea then what is other solution that could be used for mobile chat applications?
Don't forget that on iOS user may forbid sending notifications, so your app won't receive any even in foreground. Thus, you need to implement your own push mechanism.
Need for push notifications
Especially on iOS you don't have a choice but to use their push notifications service APNS. There is no other way to receive notifications immediately because iOS may kill or neglect the TCP connections of your background app.
On Android it seems possible to use your own background TCP connection to avoid having to use push notifications. But you may still consider the use of the push notifications through GCM for the sake of improved battery usage.
Pricing
Neither APNS (iOS) nor GCM (Android) charge you for the service and you are allowed to send an unlimited number of messages.
Limitations and Requirements
Both services will delete message, when there are too many messages accumulated in the queue for an offline device - which makes sense because there is no point in delivering those messages hours later. You have to take that in to account, when writing your app (just do a poll when going back online).
Depending on the app you are writing, there may also be privacy concerns. Even if you encrypt the message itself, at least Apple/Google know when a notification is sent to a certain device, which may be a deal-breaker for certain high-security applications.
You will also need a server that is able to communicate to both APNS and GCM. There are open source solutions for that (e.g. easyApns for iOS and python-gcm for Android), but how easy their integration is depends on your server and the language it is written in.
the thing is that we already have a backend that handles all the push notification process. From device registration on our DB and notification handling on the device and notification sending to Apple and Google servers...Looking into Parse I saw that it has a lot of things that will take us a lot of time to develop but mostly on the process that sends the notification to the devices.
So...I need to know if devices can register in our backend, then from our backend to Parse and then send push trough Parse. Is this possible? Image below.
Thanks!!
Yes this is possible. You'll need setup your push certificates with Parse and register each device's push token with a Parse Installation object's deviceToken field for it to work. All this is documented on their web site. You'll need to setup a Parse User object for each user as well as each Installation is associated with a single User.