#1 2017-06-07 07:25:15

Kasito
Banned
Registered: 2016-08-05
Posts: 58

How to implement certain Cordova's plugin in my app

I found this plugins very useful

cordova plugin add https://github.com/sdkcarlos/cordova-ou … nshots.git

I have installed it successful, but Executing it im have issues.

This is the javascript to be called.

document.addEventListener("deviceready", function(){
    var successCallback = function(){
        console.log("The screenshots are not allowed now.");
    };

    var errorCallback = function(err){
        console.error("An error ocurred : " + err);
    };

    OurCodeWorldpreventscreenshots.disable(successCallback,errorCallback);
}, false);

So i created a Function in AB and pasted it as above then i called the Function by typing the function name in the page Show of  the specific page i needed the action to be triggered .

Remember i just pasted the code in the function i created "PreventScreen"

Do i have to StartJS and EndJS for pasted script.  Because  it is not executing.

Please i will appreciate any clarification.

Thanks

Last edited by Kasito (2017-06-07 07:27:59)

Offline

#2 2017-06-07 15:47:14

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: How to implement certain Cordova's plugin in my app

Hello kasito,

You can't simply copy and paste Javascript code "as is", without understand where and what Javascript you must use. For example, the above code attach a function to be called when the device are ready, but App Builder already have an event named "Ready", which correspond with the event you try to use.

So try with this code in the app's Ready event:

var successCallback = function(){                                     
    console.log("The screenshots are not allowed now.");              
};                                                                    
                                                                      
var errorCallback = function(err){                                    
    console.error("An error ocurred : " + err);                       
};                                                                    
                                                                      
OurCodeWorldpreventscreenshots.disable(successCallback,errorCallback);

Offline

#3 2017-06-07 18:31:20

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How to implement certain Cordova's plugin in my app

Hi. David

I implemented as you suggested but it still  didn't trigger.  But im sure is an issue of implementation, i wish you try at your end and figure it for it out.    The plugin seems to be useful for screen shot prevention.

Thanks.

Offline

#4 2017-06-07 18:32:46

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: How to implement certain Cordova's plugin in my app

Hello kasito,

I forget the StartJS and EndJS action in my above code... are you try it with that actions?

Offline

#5 2017-06-07 18:43:57

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: How to implement certain Cordova's plugin in my app

Hello again,

Anyway this plugin has some problems to be propertly installed:

xf8vt0u.png

Offline

#6 2017-06-07 19:03:21

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How to implement certain Cordova's plugin in my app

Oh. Quite unfortunate at your end. I installed successfully, i will try with the StartJS and EndJS to see.

Thanks for the efforts. Though i downloaded it manually then copy and pasted the extracted folder to the plugin folder. Then during build, in installed automatically.

Im sure you cal figure that out if you have time.

Offline

#7 2017-06-07 19:20:52

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: How to implement certain Cordova's plugin in my app

Hello kasito,

You need the "StartJS" and "EndJS" actions without doubt, because you are try to use pure Javascript code. On the other hand, the installation error persists here: apparently there is a problem to download the plugin or they are not well configured or well formed, according to the error message we can see above.

Offline

#8 2017-06-14 13:30:50

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How to implement certain Cordova's plugin in my app

Hi David

I got it working with the StartJS and EndJS.   Although i have an issue with the app. When i launch the app and it becomes ready,  the Javascript doesn't trigger, until i restore and maximize the app using android button before the Javascript (plugin)  switch into action. 

This im sure is the app issue because i have had similar problem with other apps i build without external Plugings. 

How can thus be resolved?  Script not triggering until you go to next page or you have to restore and maximize.  The app interface (window)

Offline

#9 2017-06-14 13:48:59

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: How to implement certain Cordova's plugin in my app

Hello,

Kasito wrote:

Hi David

I got it working with the StartJS and EndJS.   Although i have an issue with the app. When i launch the app and it becomes ready,  the Javascript doesn't trigger, until i restore and maximize the app using android button before the Javascript (plugin)  switch into action. 

This im sure is the app issue because i have had similar problem with other apps i build without external Plugings. 

How can thus be resolved?  Script not triggering until you go to next page or you have to restore and maximize.  The app interface (window)

I think you must be more descriptive with the problem you have. What you expected? What you get? Where you place the Javascript that is "not triggered"? You get some error message? If you place other code (like an "Alert") in the same event are that code executed?

Offline

#10 2017-06-16 16:51:33

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How to implement certain Cordova's plugin in my app

Hi David

I think it's because I made minify the app Cod.   When i tried it with a new app without code minification it works perfect.

Thanks

Offline

#11 2017-06-16 17:10:36

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661
Website

Re: How to implement certain Cordova's plugin in my app

Hello,

Kasito wrote:

Hi David

I think it's because I made minify the app Cod.   When i tried it with a new app without code minification it works perfect.

Thanks

Sorry, but something like that have non sense: the App Builder's minimizer tool can minimize the Javascript and CSS code, but DO NOT alter their behaviour in any manner!

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.