Hi everyone,
I want to ask in the Outsystems mobile platform are there any component or library to detect the usage of mock location (such as fake gps) in mobile devices? We are using the official Location Plugin in our mobile app cases to retrieve device's coordinates, and can be breached with fake gps application.
And if there is none, is there any workaround to create a function that can be used in the Outsystems? Thanks before.
Hi Aditya,
Your RunChecking code is probably not right... You don't want to register a listener, you want to directly make the check.
The listener in the example from the plugin is because you need to make sure Cordova has properly loaded everything needed...
I'd remove lines 1 through 3, line 5 and lines 20 through 26 and give it a go. Just make sure you call your "check for mock GPS" client action after the "check for plugin loaded" client action.
I wouldn't expect you need any String() conversion for your outputs.
Hope this helps!
Hi
AFAIK there is no such function in Outsystems. But Outsystems mobile app can use Cordova plugin.
So maybe you should search Cordova plugin like this.
https://github.com/diegorribeiro/cordova-plugin-mock-location-checker
Regards
Tom Zhao wrote:
Hi Tom, thanks for your response.
Okay noted, how do I apply/install the plugin from github resource? Can I put it to my main module directly (via extensibility config?) or do I have to create a plugin first?
Aditya Eka Prabowo wrote:
Hi Aditya
Please check the URL bellow.
https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/Mobile_Plugins/Using_Cordova_Plugins
https://www.outsystems.com/blog/posts/how-to-create-a-cordova-plugin-from-scratch/
Hope it's can help.
Kindly Regards
Alright thanks, I will try it.
By the way, is the plugin you suggested (https://github.com/diegorribeiro/cordova-plugin-mock-location-checker) also available in iOS?
As far as I'm aware, iOS does not allow applications to override the GPS to provide mock locations (definitely not without jailbreaking), so such a plugin is only needed for Android.
In order to mimic the example code from the plugin repository, you would likely want to use the Device.whenReady() promise (you can read more about it here) instead of adding an event listener for "deviceready".
In order to guarantee you have a value for your CheckMockLocation, you need to call the mocklocationchecker.check() method and make sure both callbacks make use of the $resolve() and/or $reject() predefined functions (you can read more about them here). This will wait for the promise to be resolved before continuing the execution of the client action.
Jorge Martins wrote:
Hi Jorge,
Okay, it might not be needed in iOS devices. I have tried to wrap the Cordova plugin into Outsystems module,
but when I try to debug the javascript snippet to call the functions, it always returned "False" value even though i've been using a fake gps app. This is how I'm implemented the function in JS snippet:
The $parameters.Result using a Boolean data type variable. The $parameters.Error is a text, and it always returned "" empty.
Is this the correct implementation? Could it be the cordova plugin itself that's not working anymore?
Hello everyone, I want to ask and update some progress regarding this case..
Just like my post before I chose this plugin for my case: https://github.com/diegorribeiro/cordova-plugin-mock-location-checker
For initial check plugin action, I wrote this code inside the JS node:
The output value are able to returned "true" boolean variable, I assumed the plugin is loaded. So far so good. Then I wrote this code inside the "main" action for running plugin functions:
I followed what Jorge has been telling about asynchronous js code. inside the js node I'm using String() function because previously it creates an error that JS object cannot be assigned to text/boolean/any data type in OS.. then here it is the output from the js node functions:
it is converted into text but, it literally convert the result as an "object" text.
My questions is:
1. Can I convert the object to more defined output? Even the github documentation said the result is using true or false boolean data type.
2. Am I doing it wrong? The reason why I'm using String() function instead of JSON.Stringify for converting object to text is because it causes hang or stuck in the process.. the mobile app suddenly just freeze.
Thanks before
Hey everyone, I finally work it out.
Previously I didn't know the JSON.stringify() function is case sensitive (or anything in JS), instead I wrote JSON.Stringify() with a big "S" inside the JS node.. this is why the app freeze when it tries to convert. So this is what I pretty much did:
The JS object is converted into text within JSON.stringify() function, and then pass it to the text output parameter. The plugin returned an array with four fields, one of the field determines the usage of Mock Location -- this is exactly what I need. It must be converted into text otherwise it will fail to pass the output (any data type except Object).
The solution that Jorge has mentioned is also work, in fact it's what I've been using right now:
I'm still using the data conversion in here. I haven't try not to using conversion but still, the plugin did work. Probably I will update it later.
And this is the final result, the output from that JS node:
It returned "mock-true" when I'm using a fake gps and the mobile app at the same time.
But unfortunately there is a cost.. when running the plugin action it takes some significant time to load. Is it because i'm using github online repository instead download the files and put it inside the OS module? Should I download it and put the plugin files into resource folder?
Anyway thanks everyone who helped!
No, the GitHub repository is only used when building your native application. It's likely because determining that takes time and you are using $resolve() to wait for the outcome.
If you can call some callback Client Action on your successCallback() (and potentially a different Client Action on your errorCallback()), and not have any output parameter on your "check for mock GPS" you would avoid this delay. The logic that deals with the outcome of your check would then need to be on the callback Client Action.
Maybe this can help offset the wait somehow...
Alright then, so Github repository doesn't affecting the load on screen.
Is what you mean to call another client action inside the JS node? And after reaching the second client action, then I print the output that determines mock-location being used? If that so how to call a client action inside JS node or how do I write?
When the second action is called, you can pass it the result you have will be called after you alhaving a result so
You can learn how to call Client Actions from JavaScript here:
$actions.YourClientAction(result);
Available Client Actions will actually show on the list of actions on the JavaScript editor, dragging-and-dropping or double-clicking one will insert the required code. You can also drag and drop directly from the Logic tab to the editor.
Now, whether you can use this or not depends on how you are implementing this functionality in your application...
Hi, @Aditya Eka Prabowo i want to ask you something about your logic to check mock GPS, because i got a case that I need to check the mock too... soo earlier you said that your result variable was a boolean type, but the final result was in text list type ? can you explain more about your logic from "pluginIsLoaded" JS until "RunChecking" JS ? that will be very helpful :D