Cordova - Android - Notification and icon when getting location - android

I am making an Ionic App where I use the cordova geolocation plugin. In Android 8 only, I am getting a notification with an icon which isn’t the icon of my App. Is it possible to change this icon and the texts or remove the notification?
I am calling the method to get my position like this:
this.geolocation.getCurrentPosition({ enableHighAccuracy: true, timeout: 1000, maximumAge: 1000 }).then(...
And this is the icon I am talking about (the one about fusedlocationprovider):
https://sjc1.discourse-cdn.com/ionicframework/uploads/default/original/3X/e/4/e42576b221bd6c9aef4c124e297e0b1eaf626d5a.jpeg
Is there any way to do this? I guess it is something I can configure in config.xml most probably but can't find out what it is.
Thanks!

Related

In Codename One, can I badge an android application icon?

I would like to have number badges on my application Icon set with a LocalNotification (ie: how many items are still unread in the app after the last session). I set a local notification to test this behavior using the following code and on Android, all I get is a top-bar notification with the number 10 in it, but no badge:
LocalNotification n = new LocalNotification();
n.setId("updatedLearnableCountBadge");
n.setBadgeNumber(10);
Display.getInstance().scheduleLocalNotification(
n,
System.currentTimeMillis() + 1000, // fire date/time
LocalNotification.REPEAT_NONE // Whether to repeat and what frequency
);
Is Badging on Android not implemented yet, or am I doing something wrong?
LocalNotificaiton doesn't mention any special conditions required to make the "setBadgeNumber" display properly, but are there some undocumented platform-specific conventions I'm not following here?
As far as I know Android itself doesn't support badging. It's a feature of iOS which we exposed due to user requirement but it can't be implemented outside of iOS to my knowledge.

Q: Cordova Phonegap Geolocation getting the right speed?

I made an app that tracks users location now i need to get the speed also. I manage to put position.coords.speed but it always shows 0. I noticed that the gps tracker/icon is not actively tracking. What is the best practice on tracking the speed of the user? I am using the plugin cordova-plugin-geolocation
Have you requested high accuracy in the options when requesting location? For example:
navigator.geolocation.watchPosition(onSuccess, onError, {
enableHighAccuracy: true,
timeout: 30000,
maxAge: 0
});
If position.coords.speed is zero and the gps/location icon is not shown in the taskbar, this might be the cause.

How to run background service in phonegap even will close [duplicate]

I have used the system notification plugin from the github(https://github.com/saileshmittal/phonegap-system-notification-plugin) for android phonegap.I have used this code in my index.html
My code is:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var not_title = 'Message';
var not_text = 'Zou dit werken?';
var not_tText = 'Message';
navigator.systemNotification.onBackground();
navigator.systemNotification.onForeground();
navigator.systemNotification.createStatusBarNotification(not_title, not_text, not_tText);
}
I got the notification icon in both foreground and background.But is it possible to run the whole application to run in the background when the button is clicked in the application and call my wcf services continuously.Also i need to get the alert even when running in the background.how to do that?
navigator.systemNotification.onBackground():this line run the application in background or not other wise it only for showing the notification after closing the application.
please guide me,thanks in advance.
I made an Android application with PhoneGap and when I press the home button, my application stays in background (with my last test it stays more than 1 hour). But when I launch other App the Android OS kills my application.
To enable this behaviour you need to add the android permission:
<uses-permission android:name="android.permission.WAKE_LOCK" /> to your manifest
and you also need to add:
<preference name="exit-on-suspend" value="false" /> to your config.xml in folder res/xml
I hope this post can you help you :)
According to the phonegap documentation you cannot run the apps in the background, the js cannot continue to run. The reason notifications are able to work is because they are using the native system to send the notifications.
In order to make processes run in the background you will need to create a plugin that uses the native os.

watchposition fires every minute on Nexus-5

Geo-location watch only fires every minute. Using a Nexus-5, android 4.4.2, and cordova 3.3.1 (I've also tried 3.4.0). It makes no difference what I define maximumAge as. The location returned is correct. In other devices I have have tested it gets fired every second. I know I can fall back on using setTimeout with getCurrentPosition, but I'd like to understand this behaviour.
navigator.geolocation.watchPosition(
function(){
console.log("success");
},
function(){
console.log("fail");
},
{
enableHighAccuracy: true,
timeout: 30000
}
);
The Geolocation Plugin is not that great, and will actually be deprecated in the next Cordova release. They suggest that you just use the HTML5 Geolocation API instead, which uses the same syntax.

navigator.geolocation.getCurrentPosition fails on Android Browser

i'm trying to get the geolocation on Android Browser but nothing happens. I'm using a Samsung Galaxy S3 but i'm not sure about the version of my browser. Android version is 4.1.2
Here is my Code:
if (navigator.geolocation) {
var timeoutVal = 10 * 1000 * 1000;
navigator.geolocation.getCurrentPosition(
displayPosition,
displayError,
{ enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 0 }
);
}
this is a code i copied and pasted from this site
it gives me the "navigator.geolocation"
but when it comes to "getCurrentPosition" my code stops working. Mobile Chrome works fine but this is not. I shared my position but still nothing happens. Any help will be appriciated.
Thanks.
Thanks everyone i found the solution,
i was getting the geolocation after some javascript operations. I tried to get the geolocation before document is ready. And it worked.
I know this is a bit old but it keeps coming up on searches so I thought I would add a tip that helped me.
Because I want to get the location right as the page loads I found that I needed to introduce a very short delay after the page loads. When I had no delay, I would get no error but also I would not activate the location protocols on the phone. This half second delay solved the issue. You can play with the delay and see if it solves your issues.
setTimeout(function() {getAutoLocation(true)},500);
I get the location in my "getAutoLocation(true)" function. This setTimeout only exists to introduce the delay.
seems like PhoneGap has a problem with geolocation
I have the same issue
I'm using S3 with Android 4.1.2, phonegap geolocation feature doesn't work
In order to get the geolocation without errors, you have to make that code block work before using the values provided by the geolocation because operations are carried out asynchronously, in this question i found the solution by loading my geolocation script before other .js files. This solved my problem and another trick for this issue is, geolocation works more stable when you give "always" permission for browser to read your location. After loading for the first time, you never encounter geolocation errors.
I found that some Android phones (old and new) don't run properly the function
getCurrentPosition, maybe trying to save some battery.
I played with the function watchPosition and then the high accuracy GPS kicked in.
Read this to know how to use the parameters properly:
http://dev.w3.org/geo/api/spec-source.html#watch-position
In my case, this worked:
{
maximumAge: 0, timeout: 2000, enableHighAccuracy: true
}
Hope this helps someone.
Did you give Internet permission in manifest?
<manifest xlmns:android...>
...
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>

Categories

Resources