Cordova background modes issues on Android/iOS - android

I've ran into a problem with apache cordova background modes. I need to make an application where my battery level is checked from time to time in the background (if the app is in background), and if it is below some level, then the app should notify you about it. Eventually I've managed to run it on android, with katzer's plugin, it does work indeed, but after a while it shuts down completely and on iOS it does not even work. I've tried other plugins but nothing was helpful. Can you please help me find the problem with this? Also it must work on wp8/8.1 that's why katzer's plugin suited me best. (Not to misunderstand me, it is an outstanding plugin, in fact the only that works).
Here is the code on Pastebin
Also I'm linking the plugin which I'm using at the moment
Thanks in advance

Related

Foreground service example in Flutter

I am new to Flutter. Can anyone post the link or code for "android foreground service example with a notification"? I googled but didn't get any good example of foreground service.
I'm working on a project that includes an SMS package. This App has to be active on the foreground.
Update:
I have created my own implementation of android foreground service for Flutter called android_long_task. check it out it solved my problem. let me know if it solves your problem by raising an issue.I created my own library because the tutorial I mentioned just shows how to create a foreground service in java and that's all and as you have found out by now the other foregorund_service plugins have some problems.
Old answer (didn't help me):
if you're having a problem with this and none of the libraries mentioned in other answers worked for you. you might wanna give this tutorial from RetroPortal Studio a try. it's a total of 26 minutes which teaches you how to write a working foreground service for flutter android
I tried flutter_foreground_service but it has a big problem. When app closes this plugin throwing error. This bug is reported in here: https://github.com/pauldemarco/foreground_service/issues/1
foreground_service has problem too: https://github.com/pauldemarco/foreground_service/issues/1
Probably there isn't a good solution for now (Jan 2020). If someone develops a good solution may be I add it to here.
I think Google should find solution for this kind of problems. We're using flutter becouse we're thinking that flutter is more effective. If we lost our time kind of this absurd errors why we using flutter? Using kotlin for android, swift for ios this is more good probably.
Pauldemarco has created some excellent flutter packages for flutter. He has developed one for Foreground service too. As of now, it is only supported in android. It is not supported for iOS. I hope this helps.
https://github.com/pauldemarco/foreground_service
You can use library flutter_foreground_task for long or always running task.

Getting an App APK

Hey guys and girls for a the past week I've grown a lot of interest in android studio (even without knowing quite much about it) I decided to create an app that I deemed quite useful. However the app required maps to be integrated in it and I really did not know what I was doing and at one point I started messing with the settings and then all hell broke loose and I kept getting AAPT2 errors and I even tried to fix this issue with the gradle properties line that you add (I forgot the line of code to add). Anyways it still didnt work. However I rembered that I always kept the good version (before I broke everything) of the app on my phone. So when I go in my phone the app is there and it works just fine. Ive tried so many things to get the source code from the app on my phone without any succes. My question is, how can I get the source code back from the working app onto my laptop to continue coding in android studio? If it helps I am using Linux 18.04 LTS and running the newest version of android studio. Thank you for any help from you guys. This means a lot to me.
You can’t get back the ‘source code’ from an already compiled app.
You should consider using some version control platforms like git from the next time

How can I change the app icon and name of an Ionic app during runtime?

I'm trying to hide my app or change the icon and name after the user takes some action, I don't know if there's a way to do this because the main idea is the app looks unnoticed for other users besides the phone owner.
I've been reading some things about how to do this on android but I can't find anything on ionic or cordova, so I'm looking for some guidance to do this
I hope you can help me!
I don't understand why you would need to change the app icon or name depending on what the user does, but even then, all of the things I have read conclude that there is no way to do this, at least on iOS.
You can check out some similar questions here, here and here. Although I must admit that these resources are quite outdated. Regarding your question, the only technology within Ionic that would be able to do this is Cordova and if it is not possible natively, which seems to be the case for iOS, then there is nothing that Cordova can do.
If you have found a way to do this on Android, then you would have to build your own Cordova plugin to handle it, because there doesn't seem to be anything out there that can do this.
you can do this on iOS 10+. check this out:
https://github.com/EddyVerbruggen/cordova-plugin-app-icon-changer
haven't been able to find a solution for Android yet, if it is possible at all.

Android Cordova 5.0+ Camera crash

We are using Cordova 5.0.0 and its cordova-camera-plugin
When we are testing it on Android, the app crashes when the user takes a photo.
Looking at the links below, it seems that our app is being killed while the camera app it on front.
PhoneGap camera restarts the application
https://github.com/shaithana/cordova-plugin-wezka-nativecamera
While there are some answers but it seems to be outdated: The foreground camera plugin is not suitable to newer devices or Cordova and other solutions didn't work for us
Does anyone have an up-to-date solution?
Try to use this forked cordova-android and cordova-plugin-camera.
The docs, sample and discussion on the approach used can be found in the cordova-android PR.
BTW, the PRs are going to be merged soon.
First question that comes to my mind is: Why using this camera plugin: https://github.com/shaithana/cordova-plugin-wezka-nativecamera
It's obviously a fork. You might have a good reason for that. It's also outdated. Last contribution was one year ago.
Maybe you want to give the "official" plugin a shot:
https://github.com/apache/cordova-plugin-camera
Going deeper into detail without knowing more about your testing environment (which device(s) with which Android version) and without having possibility to review entire related code, is not possible and answers may not give any reliable advice for change.
Have you ensured, that the call to the camera plugin cannot happen before "deviceready" was triggered? Is cordova.js loaded?
Update:
You may also want to switch from raw alerts to console output. I recognized several times that alerts in callbacks triggered from plugins could cause some trouble.
As a general rule of thumb: Use console.log() instead of alert() and connect with Chrome (chrome://inspect) to the emulator or device to see what happens. You can additionally use adb logcat to have a look into the device log.

Local Notifications in Cordova 3.0.0

I am developing a Cordova 3.0.0 application which needs to periodically show notifications to the user. They need to be the kind of notifications that live in the notification center on iOS; modal popups aren't good enough as the app may be running in the background at the time.
The built-in Notification plugin only provides modal popups: http://docs.phonegap.com/en/3.0.0/cordova_notification_notification.md.html
I have seen 3rd party plugins, such as this: https://github.com/DrewDahlman/Phonegap-LocalNotification
- however, they are developed for much older versions of Cordova/PhoneGap.
Is it possible to use any of these with Cordova 3; or is there a better way to do it (device-independently if at all possible, as I need to have similar behaviour on Android as well as iOS); or would my best option be to downgrade to an older version of Cordova?
Thanks
Drew Dalhman's Plugin still has some Issues. For example cancel() and background callback do not work.
This one, from Sebastián Katzer is updated and works with Cordova 3+ :
https://github.com/katzer/cordova-plugin-local-notifications
for iOS, Android and WP8
According to the issues for Drew Dalhman's plugin some people have had some success using that plugin in Cordova 3.0.6:
https://github.com/DrewDahlman/Phonegap-LocalNotification/issues/18
Rather than downgrading to an earlier version I'd look to see if a pull request can be created for the plugin. This will help everyone and will allow you to take advantage of Cordova improvements.
I was actually researching this same issue earlier for Android. Not implemented anything yet, but this tutorial seems to have some useful information (Part 3 is most relevant to showing notifications):
http://red-folder.blogspot.co.uk/2012/09/phonegap-service-tutorial-part-1.html
I googled but couldn't find anything.
My suggestion would be that you write your own plugins/extensions for Android and IOS respectively. It isn't difficult. The problem with writing your own IOS plugin is that you need to have a mac and iphone/ipad. Also, try the Phonegap-LocalNotification plugin you mention, it could possibly work.

Categories

Resources