Get location using wifi or mobile network Tizen Web app Smartwatch - gps

Currently i am creating an application for the samsung gear s smartwatch using tizen web application (javascript). My widget/app needs to get location data (it's a safety application) everywhere. The basic GPS location works fine as you can see in my code below. The problem is that GPS only works outside, since my app is a safety app i need to get location everywhere. On phones you are able to use Wifi and mobile network to get location. My question is is it possible to get location data using wifi or mobile network on a smartwatch (the samsung gear s has mobile network and wifi connection so you would think that it is possible)? and if it's possible how.
My code for the basic GPS location using HTML 5 geolocation:
function getBestGPSLocation(){
//GPS
navigator.geolocation.getCurrentPosition(success, error, {maximumAge:60000, timeout:5000});
//Wifi
//Mobile Network
}
function error(error) {
// just some error codes they work either
switch(error.code) {
case error.PERMISSION_DENIED:
console.log("permission denied");
break;
case error.POSITION_UNAVAILABLE:
console.log("your position is unavailable");
break;
case error.TIMEOUT:
console.log("a timeout occured");
break;
case error.UNKNOWN_ERROR:
console.log("an unknow error occured");
break;
}
}
function success(position) {
// this works i get all the data
alert(position);
alert(position.coords.latitude);
}

Related

Xamarin.Android : The connection to Google Play services was lost due to service disconnection

I am currently trying to test an Xamarin.Android App on both Emulators and Physical Device.
I am using Firebase to try and register users or login with already existing users.
On either of emulator and physical device. I get the response failure message:
The connection to Google Play services was lost due to service disconnection.
Here is the full error received.
{Android.Gms.Common.Apis.ApiException: 8: The connection to Google Play services was lost
--- End of managed Android.Gms.Common.Apis.ApiException stack trace ---
com.google.android.gms.common.api.ApiException: 8: The connection to Google Play services was lost
at com.google.android.gms.common.api.internal.zaab.zaa(com.google.android.gms:play-services-base##17.2.1:32)
at com.google.android.gms.common.api.internal.zaab.zaag(com.google.android.gms:play-services-base##17.2.1:18)
at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.zabf(com.google.android.gms:play-services-base##17.2.1:49)
at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.onConnectionSuspended(com.google.android.gms:play-services-base##17.2.1:44)
at com.google.android.gms.common.internal.zag.onConnectionSuspended(com.google.android.gms:play-services-base##17.2.1:4)
at com.google.android.gms.common.internal.BaseGmsClient$zzb.handleMessage(com.google.android.gms:play-services-basement##17.2.1:40)
at android.os.Handler.dispatchMessage(Handler.java:106)
at com.google.android.gms.internal.common.zzi.dispatchMessage(com.google.android.gms:play-services-basement##17.2.1:8)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)
}
void RegisterUser(string name, string phone, string email, string password)
{
taskCompletionListener.Success += TaskCompletionListener_Success;
taskCompletionListener.Failure += TaskCompletionListener_Failure;
try
{
if (mAuth != null)
{
mAuth.CreateUserWithEmailAndPassword(email, password)
.AddOnSuccessListener(this, taskCompletionListener)
.AddOnFailureListener(this, taskCompletionListener);
}
}
catch (System.Exception)
{
}
}
Any help regarding this issue?

Unable to Register IOS device to Mobile First 8

I am able to see the iOS device under devices tab in MF, registered to my application. but pushing a notification fails with the below error:
An error occurred while the notification was sent. Internal server error. No devices found.
Upon reviewing IOS code, I noticed the below issue while invoking MFPPush.sharedInstance.registerDevice(nil)
Cannot retrieve a valid authorization header for header. Check resource and authorization server configuration.
I am using the code from the git sample. Below is the snippet throwing the error:
#IBAction func registerDevice(_ sender: AnyObject) {
print("Attempting Device registration with Mobile First")
WLAuthorizationManager.sharedInstance().obtainAccessToken(forScope: "push.mobileclient") { (token, error) -> Void in
if (error != nil) {
print("Did not recieve an access token from server: " + error.debugDescription)
} else {
WLClient.sharedInstance()?.setDeviceDisplayName("White Ipad", withCompletionHandler: { (error) in
if error == nil{
print("device display name is set")
}else{
print("error setting device name: " + error.debugDescription)
}
})
print("Recieved the following access token value: " + (token?.value ?? "no token"))
MFPPush.sharedInstance().registerDevice(nil) { (response, error) -> Void in
if error == nil {
self.enableButtons()
self.showAlert("Registered successfully with Mobile First")
print(response?.description ?? "")
} else {
self.showAlert("Registration failed with Mobile First. Error \(error?.localizedDescription)")
print(error?.localizedDescription ?? "")
}
}
}
}
}
Mobile First Config: I have followed the documentation and configured the UserLogin security check from the sample git project and have removed scope to push.mobileclient under security.
Reading the OAuth Security in MF, i understand the that token is necessary to access resources, but I am unable to figure out how to attach the token in registerDevice().
It seems to be you haven't configured Push Notifications properly in MobileFirst Server.
Make sure that you have added push.mobileclient scope in Security tab of your application. If you are not using any security check, you can add scope like below.
Check whether your application is configured valid iOS provisioning profile enabled with Push Capability
Make sure that you have uploaded valid sandbox/production certificates in Push tab of your particular app in MFP Operations Console.
More details : here
Make sure your app is enabled Push Capability in the project setting and also check you sending device token to MF Server using MFPPush.sharedInstance().sendDeviceToken(deviceToken) API in didRegisterForRemoteNotificationsWithDeviceToken method of AppDelegate file
-

Apple Push Notifications not arriving on iOS device from Microsoft Azure Notification Hub

I have followed-up the tutorial Microsoft Azure Notification Hub for iOS apps till the end and successfully registered device for push notifications. When I send a test notification from Debug option in Azure Classic Portal the Result shown with options Registration ID (XXXXXX12345), Platforms (apple) and Outcome says "The Notification was successfully sent to the Push Notification System" but my device is not receiving any Notifications. I have uploaded a valid .p12 certificate into Azure Portal as well. I am using azuresdk-iOS-v1.2.4 framework with iOS 9. Please help me on it.
SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString:HUBLISTENACCESS notificationHubPath:HUBNAME];
[hub registerNativeWithDeviceToken:deviceToken tags:nil completion:^(NSError* error) {
if (error != nil) {
NSLog(#"Error registering for notifications: %#", error);
}
else {
[self MessageBox:#"Registration Status" message:#"Registered"];
}
}];
Do I need to covert deviceToken into Hexadecimal? right now am passing deviceToken as it is what am getting in didRegisterForRemoteNotificationsWithDeviceToken method.

How to automate keystrokes for Blackberry J2ME Application?

I am trying to do automation testing over a blackberry application written using J2ME over MIDlet architecture.
I have an application already running on blackberry devices. I am writing my TestApp (written again in J2ME) over existing App. (i.e., my TestApp extends to already Original App and it runs - inheriting).
I am trying to run the OriginalApp through my TestApp and handle the controls automatically using my TestApp. I am not able to automate the key strokes although I have already got the key codes of the blackberry device.
Keycodes I am using are like
KEY_BB_FIRE = -1204;
KEY_BB_UP = -1200;
KEY_BB_DOWN = -1201;
KEY_BB_LEFT = -1202;
KEY_BB_RIGHT = -1203;
I am trying to use _keyPressed and _keyReleased methods of Screen class.
boolean sendKeys(Form obj, int keyObj){
try{
obj._keyPressed(keyObj);
obj._keyReleased(keyObj);
}
catch (Exception e){
System.out.println("ERROR: Striking key in Form failed: "+keyObj);
return false;
}
return true;
}
Similarly I have got the key codes for Nokia device and I have completed automating the same application for Nokia. Just having trouble using the same technique on a blackberry.

Determine if internet connection is available

how do you folks check if the device is connected to the internet in a sencha touch app?
There's an attribute called navigator.onLine (general browser support, not specific for Sencha)
If I'm in a PhoneGap application (which you often are if you're using Sencha Touch), I'd rather use their network.isReachable function, since I've by experience found it more reliable.
There's also something called 'Offline events', John Resig describes them on his blog: http://ejohn.org/blog/offline-events/.
If there is no network connection during an ajax request sencha touch will return a response with a 0 status. So this is what we're using in our app (works in phonegap too):
// global error handling
Ext.Ajax.on('requestexception', function(connection, response) {
// get rid of any loading masks that are present
Ext.each(Ext.query('.x-mask'), function(el) {
new Ext.Element(el).hide()
});
switch(response.status) {
case 0 :
Ext.Msg.alert('Error Loading', 'No Internet connection.');
break;
case 401 :
Ext.Msg.alert('Login Failed', 'Check your username and password.');
break;
default :
Ext.Msg.alert('Whoops!', 'An unexpected error has occurred and we have been alerted.');
}
});
Note that this is for touch 1.1, haven't tried in in 2.0 yet.