Get Id onesignal Cordova plugin

Asked

Viewed 279 times

1

I’m having trouble picking up the id from onesignal device.

I am trying to use the following method:

var getId = function(){
window.plugins.OneSignal.getIds(function(ids) {
  alert('getIds: ' + JSON.stringify(ids));
});
}

Before that I am starting the onesginal and is receiving the notifications normally.

 window.plugins.OneSignal
.startInit("APP_ID")
.handleNotificationOpened(notificationOpenedCallback)
.endInit();

console is giving this error:

Refused to execute inline Event Handler because it violates the following Content Security Policy Directive: "default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-Eval". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline Execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

  • Besides Cordova, which framework you’re using?!

  • none, just testing the notifications

  • solved changed to this goal <meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; style-src 'self' unsafe-inline '*; script-src 'self' unsafe-inline 'unsafe-Eval' *; img-src * data: 'unsafe-inline'">

  • Cool, you can insert the answer in your question yourself.

1 answer

0


Solved, when added this tag in html solved the problem

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.