Broadcast receiver for checking internet connection in Flutter - service

I want to send an email. But if there is no internet connection I want to listen if the connection is resumed, and try to send the email again. Even when the app has been closed.
Is there an equivalent for BroadcastReceiver and Service in Flutter?
It should work on Android and iOS.

Currently, there are new versions of plugins mentioned in the comment by Günter Zöchbauer.
connectivity_plus
android_alarm_manager_plus
And for the alternative of android_alarm_manager_plus for iOS, this blog post featured workmanager plugin. Which uses the newer WorkManager API
The fluttercommunity as mentioned here, is currently working on this feature that will closely match the existing Android workmanager implementation.
See also "Checking Network Connectivity In Flutter" for some good sample of implementing connectivity plugin.

Related

Can you trigger workflows and send data without user voice?

Suppose I had a bluetooth low-energy (BLE) device that periodically needed to send sensor data to my server. And I wanted to use a Google Home Hub as a proxy to send this data. Is it possible to send periodic actions or do all actions have to be triggered by a users voice?
From the documentation I see you need a Android App or Google Home App but can I build custom message interfaces without one?
This can be made to work using two important aspects for smart home integration :
Local Home SDK , which enhances your smart home integration with Google Assistant by adding a local fulfillment path to route smart home intents. More information about how this works can be found here, https://developers.google.com/assistant/smarthome/concepts/local
Seamless Setup using Bluetooth Low Energy . Since BLE devices do not have a companion cloud fulfillment implementation, asynchronous state changes must be reported locally through the Local Home SDK. We would need to implement the connection event handlers, AUTOCONNECT and DISCONNECT. Also, implementation for subscribing to notifications from BLE devices needs to be carried out using REGISTER_FOR_NOTIFICATION command to the device using the DeviceManager API. Other steps to be carried out are for reporting characteristic state changes through PARSE_NOTIFICATIOn intent handler. More information about working around with this can be found here, https://developers.google.com/assistant/smarthome/develop/seamless-setup#reporting_local_device_state

How to create websocket server running inside Flutter app?

I want to create an app for some simple multiplayer game but I don't know how to create websocket server in Flutter. Any ideas?
You could use the SocketServer class (TCP). I have used this for a similar problem.
For a more complete answer, take a look at:
Using Flutter App to run SocketServer and communicate with other phone via Socket
flutter has got it covered in a very decent manner in its documentation check out
here

Is there a way to check the strength of internet connection in flutter?

I am trying to upload some multimedia files(Images, Audio and Videos) to my server and I only want to upload these files if there is a stable internet connection. Is there a concrete way to achieve this?
One year after, there is a new (Mar. 31, 2020) package that solves this need.
Check at https://pub.dev/packages/internet_speed_test#-readme-tab-
there no way to check that currently . but You can try to upload or download a file and calculate the time it took
You can use dart's connectivity_plus package which is maintained by Google team, according to its documentation :
"This plugin allows Flutter apps to discover network connectivity and configure themselves accordingly. It can distinguish between cellular vs WiFi connection. This plugin works for iOS and Android."
This way you can use the plugin to determine whether the user is connected over Wifi and if so upload the data, otherwise not to upload and wait for connection type change.

How to fully integrate in bb10 hub like WhatsApp?

The latest version of whatsapp was integrated in bb hub. when click on message item for whatsapp in hub, will open a card UI that can send and receive message.
but it still able to send and receive message when I close whatsapp, how to achieve it?
Card and app has own process and context, need across-process communication(card communication with application)?
It has been reported, and widely held, though I have never seen any official documentation it is none the less probably true that the WhatsApp developers were given early access to Hub integration APIs that are not yet widely available to third party developers.
There's a good deal of information out there now for anybody looking to find it. There's a handy page on BlackBerry Hub Integration for C and C++ (native) developers. You basically need to use the UDS (Unified Data Source) Library to open a connection to the BlackBerry Hub and register your app with the Hub.
This page has a lot of example code related to Hub integration. The basic steps are:
Open a connection to the Hub.
Register your app with the Hub.
Retrieve your service ID via the UDS.
Add an account.
Add and manipulate inbox list items on the Hub.

how to make my server support APNs?

i read in some stackOverflow post that The host would need to have port 2195 open and support push notifications under apns.how do i make my server to support apns.
what does this line means in Push Notification guide
To establish a trusted provider identity, we should
present this certificate to APNs at connection time using peer-to-peer authentication.
do i need to make a connection to APns through my native app? someone please explain this
Pretty much any server that doesn't have restriction on what sockets you can open is ready to be an APNS provider. In your project code, you can just open a socket to Apple servers (or use a library).
My understanding that Google App Engine and basically any traditional shared web hosting block any port other than 80, so you cannot use them. However, you can look into Urban Airship that provides a RESTful API that basically use from any service. It might get pricy though.
In short you need to establish an SSL connection, and then send the payload in the pre-defined binary format.
alt text http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Art/aps_provider_binary.jpg
See this guide for more details.
I use appengine, so I solved this by renting a super cheap server in hetzner.de. It basically serves as proxy to my appengine app and uses this library: https://github.com/notnoop/java-apns
that library has a one line way to send the message, using the certificate.
Google just opened up the ability to do Socket stuff on AppEngine, so I created a sample project that you can use to send push notifications using GCM and APNS in python. Feel free to use any of it that you like.
I've also included a sample iOS project and Android project that hook up nicely with the app engine solution.
https://github.com/GarettRogers/appengine-apns-gcm
** Full Disclosure ** this is my project, and I'm in no way trying to promote it because it's mine... it's simply the only available project that solves your problem at the moment. If you find anything that does a better job, please leave a comment.
You may 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