location data for symbian - javascript

I want to retrieve location data (latitude and longitude) from symbian phone with its web browser with getlocation api. Is there anyway I can do it? any api to recommend to get location data from gps enabled symbian devices? Thanks!!

I would recommend checking out phonegap http://www.phonegap.com
They have a geolocation api, but I don't know which versions of Symbian that support it.
Also look into APIbridge on forum.nokia.com.
Nota that whether this is possible may depend very much on the version of Symbian you are targeting.

You may want to check out the open source geo-location-javascript JavaScript wrapper. Using it is as easy as this:
if (geo_position_js.init()){
geo_position_js.getCurrentPosition(function (p) {
alert(p.coords.latitude.toFixed(2) + ', ' + p.coords.longitude.toFixed(2));
},
function (p) {
alert('Error: ' + p.code);
});
}
else {
alert('Handset does not have client-side geolocation capabilities');
}
This wrapper was also discussed on Dive into HTML 5.

Related

Transmitting a File Over Web Bluetooth

I'm developing a web app that has to transmit files over Bluetooth. Is this possible, and if so, how would I go about doing that? Example code would be much appreciated. I can't find any good documentation online. Also, it must be able to run on mobile devices. I'm very new to JavaScript. Thanks
Although I would strongly advise against using bluetooth as a beginner (or in general at this time due to it being a WIP for many browsers):
Web Bluetooth is NOT available for any mobile browser except Chrome & Opera for Android and Samsung Browser
The best resource is probably MDN and the specification.
Something along the lines of:
// Discovery options match any devices advertising:
// . The standard heart rate service.
// . Both 16-bit service IDs 0x1802 and 0x1803.
// . A proprietary 128-bit UUID service c48e6067-5295-48d3-8d5c-0395f61792b1.
// . Devices with name "ExampleName".
// . Devices with name starting with "Prefix".
//
// And enables access to the battery service if devices
// include it, even if devices do not advertise that service.
let options = {
filters: [
{services: ['<Your Device UUID>']}
]
}
navigator.bluetooth.requestDevice(options).then(function(device) {
console.log('Name: ' + device.name);
return device.gatt.getPrimaryService();
})
.then(function(service) {
return service.getCharacheteristic('<Your Charachteristic UUID>');
})
.then(function(characteristic) {
// Do something with the characteristic
})
.catch(function(error) {
console.log("Something went wrong. " + error);
});

Pushwoosh Cordova API: Can two different devices ever generate the same HWID?

Our app uses HWIDs generated by Pushwoosh as a key to differentiate devices. Looking over traffic logs, I am seeing what looks like the same device submitting HTTP requests from several different ISPs over short timeframes.
It appears that different devices from all over the internet are generating the same HWID, which our app is treating as the same device causing issues with users interfering with each other. Our data is showing about 50 requests appear to be from different devices, but using the same HWID.
This makes no sense to me -- from what I've read about HWIDs, they are based on the device serial number, so they should always be unique.
Our mobile app is written in Cordova, and we are getting HWIDs with this code:
get_hwid: (evt) =>
_this = #
regid = device.uuid
if evt? && evt.detail?
push_notification_id = evt.detail.deviceToken
else
push_notification_id = ""
pushNotification = cordova.require("pushwoosh-cordova- plugin.PushNotification")
pushNotification.getPushwooshHWID (hwid) ->
_this.debug 'in getPushwooshHWID callback'
_this.debug ' Pushwoosh HWID: ', hwid
_this.debug ' push_notification_id: ', push_notification_id
_this.debug ' regid: ', regid
_this.emit 'retrieved-hwid',
regid: regid
push_notification_id: push_notification_id
hwid: hwid
Has anyone observed the PushWoosh API generate HWIDs that weren't always unique?
The PushWoosh docs say that sometimes HWIDs can change on the same device, but I can't find anything that suggests that they can't be expected to be unique.
Thanks!
HWID's (which are IDFV/IDFA) are unique. The only way they may change (to another unique value) is when user restores a backup on a device.
If you see the same HWID's make sure your Pushwoosh SDK are >= 4.1.2
as outlined here
https://www.pushwoosh.com/blog/pushwoosh-sdk-update-ios-10-makes-difference/

How can i know the location of a user

I try to detect the exact location of user and specially the street if i can.
I tried that using the IP but this didn't work for me because it didn't give the exact location example for what i want is Lebanon Beirut Azarieh or Lebanon Beirut ABC Achrafieh and than i want to store this location in MYSQL database table using PHP.
i tried this code here
this code give a good location in Firefox on Localhost
but Online on Firefox and Google chrome give me that Your Location: Not Available
also it didn't work on phone browser iPhone and android (safari,chrome,...)
the idea is a user in the company want to use the website on his phone a special page on the website when he use it i want to take here exact location with the street and store this in database
You can use a flag, enableHighAccuracy:true
Here's an example code:
$(document).ready(function($){
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
latitude = position.coords.latitude;
longitude = position.coords.longitude;
//alert('latitude: '+latitude+' longitude: '+longitude);
}, function(error) {
alert('Error occurred. Error code: ' + error.code);
},{timeout:20000,enableHighAccuracy: true});
}
else{
alert('no geolocation support');
}
});
And I also want to quote that enableHighAccuracy depends from device to device.
reference here
Here is an android code link,you can get some idea from.getlocation with street

Platform-Independent JS->Native Bridge?

I'm currently working on an app that aggressively uses webviews on both iOS and Android to render content, with native chrome surrounding it. I want to be able to control this chrome via javascript methods.
Android Webview has addJavascriptInterface which allows this to happen, but iOS does not have this facility. I've already checked out the SO answer at iOS JavaScript bridge, and this has usefuleinformation, but It's iOS-only; optimally the same underlying web code could power the callbacks on both Andorid and iOS devices.
I'm wondering if something like PhoneGap or Appcelerator provides a way to do this simply; however I don't need their core product (providing a native experience via underlying html/css/js) and I dont even know if what I need is included in their package.
Thanks for any info!
I would say that the best way would be to do it yourself, combining those two examples:
function nativeDoStuff() {
if (androidbridge != null {
androidbridge.doStuff();
}
else {
//construct url
window.location = "myiphonescheme://dostuff";
}
come to think of it, if you're feeling ambitious you could code up a quick javascript object to do it for you:
function NativeAppBridge () {
function runMethod(methodName, params) {
if (androidbridge != null {
// If the android bridge and the method you're trying to call exists,
// we'll just call the method directly:
if (androidbridge[methodName] != null) {
androidbridge[methodName].apply(this, params);
}
}
else {
// building the url is more complicated; best I can think
// of is something like this:
var url = "myiphonescheme://" + methodName;
if (params.length > 0) {
url += "?"
var i = 0;
for (param in params) {
url += "param" + i + "=" + param;
++i;
if (i < params.length) {
url += "&";
}
}
}
}
}
}
Using it would then be as simple as:
var bridge = new NativeAppBridge();
function onClick() {
bridge.runMethod("doStuff", null);
}
Be aware that I coded this off the top of my head and don't have time to test, at the moment - but I think it should work well enough, provided I didn't make any major mistakes
You can try the XWebView project if you plan to use WKWebView
You can use phonegap plugins to do it. They provide an excelent way to communicate between their webview and your native layer.
Here you can see how to create one!
And my personal opinion on the subject: I've been using phonegap for a while and if you are on webviews, I strongly suggest you to rethink the way you're doing stuff and move to a mobile web platform. You probably can save a lot of time.
The way I see it, the great disadvantage on using this is you are creating a webpage instead of a mobile app. You cant use native components and your app gets less responsive. As you are already on webviews, I believe you can only find benefits on these platforms.

Get GPS location from the web browser

I am developing a mobile based web-site, there I have integrated Google Maps, I need to fill the 'From' field of Google Maps dynamically.
Is it possible to get the GPS location from web browser and fill it up in the 'From' field of a Google Map dynamically?
If you use the Geolocation API, it would be as simple as using the following code.
navigator.geolocation.getCurrentPosition(function(location) {
console.log(location.coords.latitude);
console.log(location.coords.longitude);
console.log(location.coords.accuracy);
});
You may also be able to use Google's Client Location API.
This issue has been discussed in Is it possible to detect a mobile browser's GPS location? and Get position data from mobile browser. You can find more information there.
To give a bit more specific answer. HTML5 allows you to get the geo coordinates, and it does a pretty decent job. Overall the browser support for geolocation is pretty good, all major browsers except ie7 and ie8 (and opera mini). IE9 does the job but is the worst performer. Checkout caniuse.com:
http://caniuse.com/#search=geol
Also you need the approval of your user to access their location, so make sure you check for this and give some decent instructions in case it's turned off. Especially for Iphone turning permissions on for Safari is a bit cumbersome.
Use this, and you will find all informations at http://www.w3schools.com/html/html5_geolocation.asp
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
There is the GeoLocation API, but browser support is rather thin on the ground at present. Most sites that care about such things use a GeoIP database (with the usual provisos about the inaccuracy of such a system). You could also look at third party services requiring user cooperation such as FireEagle.
Observable
/*
function geo_success(position) {
do_something(position.coords.latitude, position.coords.longitude);
}
function geo_error() {
alert("Sorry, no position available.");
}
var geo_options = {
enableHighAccuracy: true,
maximumAge : 30000,
timeout : 27000
};
var wpid = navigator.geolocation.watchPosition(geo_success, geo_error, geo_options);
*/
getLocation(): Observable<Position> {
return Observable.create((observer) => {
const watchID = navigator.geolocation.watchPosition((position: Position) => {
observer.next(position);
});
return () => {
navigator.geolocation.clearWatch(watchID);
};
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
Let's use the latest fat arrow functions:
navigator.geolocation.getCurrentPosition((loc) => {
console.log('The location in lat lon format is: [', loc.coords.latitude, ',', loc.coords.longitude, ']');
})

Categories

Resources