navigator.notification.confirm not working

This forum contains topics that were moved from Get Satisfaction
Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

navigator.notification.confirm not working

Post by Joe Sharples »

I have this code on a button click event, it used to work on ios device, but now when the button is clicked nothing happens, the confirm dialog doesn't appear.

pre

function onConfirm(buttonIndex) {
if(buttonIndex == 2){
deleteReview.execute();
}
}

Code: Select all

 // Show a custom confirmation dialog 
 // 
 function showConfirm() { 
     navigator.notification.confirm( 
         'Are you sure you want to delete this review?',  // message 
         onConfirm,                // callback  
         'Delete review',            // title 
         'Cancel,Delete'          // buttonLabels 
     ); 
 } 

showConfirm();

/pre

Any ideas why this isn't working?
Thank you

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

navigator.notification.confirm not working

Post by Serhii Kulibaba »

Hello Joe,

Please try to debug your app remotely using Weinre debugger (https://docs.appery.io/docs/weinre-de...).

Please check if there are any errors in the console.

Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

navigator.notification.confirm not working

Post by Joe Sharples »

Thanks for the response.

There are no errors when i test with the Weinre debugger.

However when testing on device (iPhone 6s, ios10) if i click the button (I'll call it buttonConfirm from now on) nothing happens, but if i exist the app and go to the home screen, or app switcher, then the confirm dialog appears, and works as expected when i go back on the app.

-buttonConfirm has been clicked but nothing shows.
Image

-Home button double clicked to bring up app switcher, dialog appears.
Image

I added some console.logs within the function, these logs don't show in the console when I click the buttonConfirm to run the function, they only appear after I have left the app.
It's as if the event isn't firing until leaving the app.

To test further - I clicked the buttonConfirm, then clicked a different button to navigate to a page which has a console.log on page show event. The page navigated, but there was no log in the console. It was only when I left the app that the logs from the function showed and the log from the page show event showed, and the dialog appeared when i went back onto the app.

This is interesting because after clicking buttonConfirm I'm still able to navigate around the app and invoke services etc, but no console.logs on the app will show until I exist the app.

I'm really not sure what is causing this and I can't seem to find any solutions on google.

Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

navigator.notification.confirm not working

Post by Joe Sharples »

-side note: I have changed the 'Cancel,Delete' to ['Cancel', 'Delete'] as
navigator.notification.confirm(string, function, string, string) has depreciated and replaced with navigator.notification.confirm(string, function, string, array)

However the problem is still the same.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

navigator.notification.confirm not working

Post by Illya Stepanov »

Hi Joe - as you might already known, we currently didn't introduced the full support for iOS 10. This might be an issue with Cordova plugin version or something else. Possibly this solution might be helpful for your case: http://stackoverflow.com/questions/38...

Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

navigator.notification.confirm not working

Post by Joe Sharples »

Thanks for your help Illya.

I've managed to fix the issue using your link.

I replaced the existing Content-Security-Policy meta tag under Source WEB_RESOURCES app PageName.html, with the following:

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

navigator.notification.confirm not working

Post by Evgene Karachevtsev »

Hello Joe,

Thank you for the update, glad you get it working!

Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

navigator.notification.confirm not working

Post by Joe Sharples »

Thanks for your help Illya.

I've managed to fix the issue using your link.

I replaced the existing Content-Security-Policy meta tag under Source WEB_RESOURCES app PageName.html, with the following:

pre
meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src * 'unsafe-inline' 'unsafe-eval'"
/pre

note: the code above should have tags around it, < , for some reason they are being removed on here

Joe Sharples
Posts: 0
Joined: Mon Aug 18, 2014 1:31 pm

navigator.notification.confirm not working

Post by Joe Sharples »

Actually the code in my previous post made it so that the image components wouldn't be visible is it's src was a url.
Use the code below instead

pre
meta http-equiv="Content-Security-Policy" content="default-src * gap:&#47;&#47;ready file: data:; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *"
/pre

Post Reply