Intel XDK + Cordova background app refresh - android

I'm looking into developing a cross-platform mobile app using Intel XDK and Cordova.
The scenario is like this:
Every n minutes (e.g. n=5) check a specific URL for updates.
If there are any updates, show or increment the badge on the app icon.
Before you say "use push notifications!" let me explain a bit more. The app I'm building will use a third-party API. Every user should keep a state of what's been seen / not seen. If I were to use push notifications I'd have to build my own backend and API that consumes the third-party API, store the state for every user and send push notifications on every update. That does seem like a major overhead.
For such a scenario iOS has 'background app refresh' since version 7. I would like to use this, but not sure how to.
So, what I would like to know is:
Can I use the background app refresh functionality through Intel XDK / Cordova and how?
How would this work for Android devices?

Related

Alternatives for cordova-push-plugin for foreground notifications on ios?

I have been using https://github.com/phonegap/phonegap-plugin-push (deprecated) and recently swapped to the more active fork https://github.com/havesource/cordova-plugin-push.
However i need my app to be able to receive notifications while in foreground. This works great on Android with the foreground variable but it does not work on iOS and there are several open issues about it on the plugin. Most people seem to do quick hacks where they add checks in "on("notification") for foreground and make their own popup in the app. This works but i want it to appear in the notification center with vibration according to the users setting like what happens on android with the "foreground" variable. so the question is.
Is there a plugin that works with cordova that does this? Or can i configure https://github.com/havesource/cordova-plugin-push to work in foreground with iOS devices?
The alternative is to use piggy back on Firebase and use https://github.com/dpa99c/cordova-plugin-firebasex
The drawback is that the plugin is huge because it does handle the whole Firebase stack but it is reliable for push notifications.

Can one implement an update system like the CoinMarketCap app in Ionic

I'm currently building an Ionic app which will be getting very frequent updates. If possible, I want to avoid sending users to the app/play store each time I push a change (which will probably happen at least twice per month).
I use the coinmarketcap mobile app a lot which seems to be built on some sort of browser rendering engine (although I don't know which one). Often, when I open this app, I get a small changelog informing me that there was an update, and can immediately start using those new features, without having to manually download the app.
Is it possible to build such an automatic update system with Ionic (React) 6 (w/o Appflow)?

How to set push notifications in android/ios with vue js?

I am trying to set up the firebase-cloud-messaging to display notifications to users. Using the web notification, everything works as intended.
However, I also want to send them via app, but apps don't recognize service-workers yet.
I couldn't wrap my head around it. How to use vue.js android/ios apps to receive push notifications? Should I use plugins? If yes, which plugins? Currently using quasar, Vue.js, FCM.
You can actually get push notifications to web and Android via vue cli setup for PWA, out of the box - iOS is the lone holdout on PWAs acting like PWAs on their devices. So, for iOS only, you'll need to create a developers account on Apple and pay $99/yr, plus 20% or 30% on all revenue on purchases...though there might be a way around that but I think that gap has been closed via recent TOS updates from Apple...for more see Netflix and WordPress issues with native apps on iOS and the fight with apple. WP being the most recent.
Pick your choice of native app building bundles, there's React native, nativescript vue, vue-native, expo and probably a few dozen more out there.
From there check the docs. Firebase has great documentation, other packages above have great documentation and they all follow a similar path since iOS has the hoops you have to jump through to get things to build.
Firebase Docs
Nativescript Docs
Push Notifications on Expo

How to Send Push Notifications to Separate Android devices Using WCF Without Using 3rd Party Services?

Why is it so damn hard to find a reliable solution for sending push notifications on your own? I need a solid solution for sending close-to-real-time notifications to separate Android devices using WCF.
I should not have to rely on 3rd party notification services like Google's FCM. I should be able to have a notification pushed to a user's device without their application running in the foreground and have that application open when the user selects that notification. Even when the phone reboots, the phone should still be able to process your push notifications without needing to start your app first.
Have any of you Pros accomplished this yet? If so, show us the code because there are way too many half-baked solutions out there that are either too old or never actually worked.
I'm using Cordova through Intel's XDK, but I don't care what environment you're using, just show us something that actually works.
Thanks
Do not use Cordova cross platform solutions for this. Either use native IDEs per platform or use cross platform solutions that translate a common code base into native code per platform.

How to track the device location (iOS and Android) device using Phonegap

I would like to know when a user arrives or leaves certain location. I was trying to do this using the wireless network (check for mobile devices), but I couldn't for several reasons.
1) I needed real time updates or every 1 - 5 min of the information about which devices are connected and which devices have just disconnected.
2) I had very high ping from my PC to my iPhone on the same network (still don't know why).
Now I want to do it using geolocation from a Phonegap application (running in the background) suspended on iOS or running in the background in Android.
Any help would be appreciated.
Update 25 May 2019
My original answer below is 6 years old and out-of-date with respect to current mobile OS versions.
For example partial wakelocks no longer work on modern Android versions.
Today my recommendation would be (if you have a serious commercial app and not a hobby project) to use the paid-for version of the cordova-background-geolocation plugin by Transistorsoft.
The free version works for iOS but for Android a license is required which costs in the order of several hundred US dollars.
However I think the price is worth it: in my 10+ years of experience in creating location-aware mobile apps, this has been the most sophisiticated and reliable solution I've encountered.
For the cost of your license, you get access to the private repo which is continually updated and maintained to be compatible with new versions of Android & iOS.
If you're looking for a free/open-source solution, I would go with cordova-plugin-background-geolocation which is an open-source fork of the original plugin by Transistorsoft.
However my experience with this plugin has been of mixed success; due to being free/open-source, it's not updated as frequently as the paid-for Transistorsoft plugin.
I encountered problems due to new more stringent restrictions on background location in recent versions of Android which took a significant time to be resolved or have not been fixed at all (see the plugin's issue list).
Original answer (11 Jun 2013)
The first thing to say is that creating a Phonegap app that receives location updates while running in the background is entirely possible, but not trivial. I've done it myself and released apps on both the Android and iOS platforms.
If you need accurate and regular position updates, I'd suggest using the GPS receiver on the target devices. In Phonegap, you can do this setting the "highAccuracy" flag when requesting position updates. The watchPosition() function will deliver new position information as and when the device receives updates from the GPS receiver, so you use it something like this:
navigator.geolocation.watchPosition(successCallback, errorCallback, {
enableHighAccuracy: true,
timeout: 10000,
maximumAge: 0
});
See the Phonegap geolocation API documentation for more details (note the permissions that are required to make this work on Android and iOS).
To keep your app running in the background on either Android or iOS you will need to setup their respective native development environments: Eclipse for Android, XCode for iOS. You will not be able to use Phonegap Build because custom settings are needed in both cases to make it work. See the Phonegap platform guides for how to do this.
To keep your app running in the background on Android, you either need to write a custom Android service, or you could do what I did and use a Phonegap plugin to acquire a "partial wakelock" (see here) to keep your app running in the background and receive position updates while the screen is off. Note that the original version of this plugin is out-of-date and doesn't work with more recent versions of Phonegap, and also doesn't support partial wakelocks. However, I've updated and extended it for my own use: you can find the source code for it in my answer to this question.
To keep your app running in the background on iOS, you need to do things slightly differently; you don't need a plugin, just a project setting.
You can either manually edit the project .plist and add the key “UIBackgroundModes” key with a value of “location” or, with your project open in XCode, add the "Required Background Modes" key with a value of "App registers for location updates". This will cause iOS to trigger the JS callback function you have registered with watchPosition() each time a location update is received. See here for more about iOS project keys and background modes.
Hope this helps!

Categories

Resources