Is there any way to create push notifications with Flutter without using Firebase (FCM)? Would it be possible to have a background job that has a socket connection to the message backend to receive the notification?
There is no way to do deliver messages to apps that are not actively being used without FCM/APNS, as that would require the process to keep a socket connection open even during this inactivity. The underlying operating systems (iOS and Android) either don't allow this to begin with, or actively kill such open connections after a short period of the app being inactive.
Related
I have an issue on firebase; the listener is connected to realtime database with personal hotspot and gets updates from database correctly, but when the hotspoter changes the network quality from 3G to LTE (or another, doesn't matter), the listener starts to not get updates from realtime database anymore. How can I detect this issue?
The Firebase SDK uses various mechanism to detect whether the socket it uses to communicate with the server is still active, but unfortunately these are not always reliable on all (especially) mobile providers.
You could enable debug logging to see what the SDK is going during those 10 minutes, or you could detect the network switch yourself and call goOffline()/goOnline in quick succession so that the SDK creates a new connection.
I'm using the sockets api to communicate with the Apple Push Notification Service, although I'm not confident I'm using it correctly...
I have an initialization function where I establish my connection to APNS. However when is the correct time to call Close() on the connection? Or do I just leave it open and keep reusing it?
Thanks!
Apple specifically request that you don't close the connection with APNS and keep reusing it as long as possible.
Keep your connections with APNs open across multiple notifications; don’t repeatedly open and close connections. APNs treats rapid connection and disconnection as a denial-of-service attack. You should leave a connection open unless you know it will be idle for an extended period of time—for example, if you only send notifications to your users once a day it is ok to use a new connection each day.
(Source)
However, Apple will close the connection if you send them invalid data (such as notifications with invalid device tokens), so your code must be able to detect that and create a new connection when necessary. You should also read error responses from Apple, since those responses will let you know if you should re-send some of the notifications after you re-open the connection.
That's a good answer from Eran but you may also check out java-apns-gae.
It's an open-source Java APNS library that was specifically designed to work (and be used) on Google App Engine.
https://github.com/ZsoltSafrany/java-apns-gae
I want to develop an application which sends a Message from iPhone to other iPhone over the internet, I want to receive the Message from other iPhone even if my iPhone is running in the background.
I have seen the WiTap application, but socket will get disconnect when application is closed or if there is screen lock.
So is that possible to develop the application so that I can receive the message even if my app running in the background forever?
From my little Knowledge, You can't do it through WiFi.
When a screen lock happened, device will automatically OFF the wifi connection for increasing battery life.Thats why socket connection getting disconnected.
In iOS, apps can’t do a lot in the background. Apps are only allowed to do limited set of activities so battery life is conserved.
But what if something interesting happens and you wish to let the user know about this, even if they’re not currently using your app.
For example, maybe the user received a new chat. Since the app isn’t currently running, it cannot check for these events.
Luckily, Apple has provided a solution to this. Instead of your app continuously checking for events or doing work in the background, you can write a server-side component to do this instead.
You can do it using Apple Push Notification Service.
It uses push technology through a constantly open IP connection to forward notifications from the servers of third party applications to the Apple devices; such notifications may include badges, sounds or custom text alerts. In iOS 5, Notification Center enhanced the user experience of push and local notifications.
More details are here
Note: details and screen shots are taken from raywenderlich website/blog.
I'm looking for any reference projects or key learning from anyone who has implemented XMPP/Jabber to successfully send notifications to iOS devices (iPhone/iPad).
I'm considering using an XMPP server (OpenFire specifically) to provide a single cross platform mobile push system. C2DM for android has a number of annoying requirements like users having Google accounts. This is what got me started looking at XMPP. I also need to support pushing to iOS devices. I know all about APNS, however I'm wondering if I could use the XMPP server for both Android and iOS platforms (and possibly more like Black Berry).
The things I feel might come up are:
iOS killing any persistent connection to the XMPP server. Will it
auto reconnect?
iOS preventing access to certain ports or protocols.
Anything to be aware of here?
Other gotchas one would only discover
by trying this?
Here you can find the answer to your first question:
when your app goes in background you (the client) close the connection
with the xmpp server. When your app comes back into foreground you
reopen the connection. If your server need to send messages to your
client, it must use push notifications. When the client receives the
notification can (it depends on the user action) go back to
foreground.
(source: iOS Backgrounding & XMPPFramework)
acani uses zimt websocket for chat. Can we make it so that when a user closes his phone and puts it in his pocket, he can still receive chat messages from and send location updates to the node.js server? I think this would be nicer than push notifications. Don't you? If not, why should we use push notifications instead or also?
Thanks!
You can't keep a network socket open, unless you are registered for voip/GPS/music playing in the background.
if you register for these, and then don't do them, apple usually reject the app.
the reason you cant keep a network socket open, is that without your app jumping to the foreground when it receives a connection, it cannot respond to network traffic(because if it is not in the foreground its memory content is frozen).
background network traffic kills the battery, as the radios in phones are one of the most energy intensive parts.
with push notifications, apple manage how often they are sent out, so you don't have all of the applications on the phone polling the network every 2 minutes killing the battery, you only have one active network connection, which is intermittent.