Skip to content

Instantly share code, notes, and snippets.

@Uriel29
Created April 14, 2016 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Uriel29/37a6ab5ed123ba896d4bd19019c14552 to your computer and use it in GitHub Desktop.
Save Uriel29/37a6ab5ed123ba896d4bd19019c14552 to your computer and use it in GitHub Desktop.
XDK project Test Onesignal
function onAppReady() {
if( navigator.splashscreen && navigator.splashscreen.hide ) { // Cordova API detected
navigator.splashscreen.hide() ;
}
}
// document.addEventListener("deviceready", onAppReady, false) ;
// document.addEventListener("onload", onAppReady, false) ;
// The app.Ready event shown above is generated by the init-dev.js file; it
// unifies a variety of common "ready" events. See the init-dev.js file for
// more details. You can use a different event to start your app, instead of
// this event. A few examples are shown in the sample code above. If you are
// using Cordova plugins you need to either use this app.Ready event or the
// standard Crordova deviceready event. Others will either not work or will
// work poorly.
// NOTE: change "dev.LOG" in "init-dev.js" to "true" to enable some console.log
// messages that can help you debug Cordova app initialization issues.
(function () {
"use strict";
/*
hook up event handlers
*/
function register_event_handlers() {
// window.plugins.OneSignal.setLogLevel({logLevel: 4, visualLevel: 4});
var notificationOpenedCallback = function (jsonData) {
alert("Message was \n" + jsonData.message);
};
window.plugins.OneSignal.init("xc1be215c-fbt88-88888-bb00-b32efe6e02e0", {
googleProjectNumber: "1899994039991"
},
notificationOpenedCallback);
// Show an alert box if a notification comes in when the user is in your app.
// window.plugins.OneSignal.enableInAppAlertNotification(true);
/* button #btn_push */
$(document).on("click", "#btn_push", function (evt) {
window.plugins.OneSignal.sendTag("Group", "My Testgroup");
// alert("Registered");
window.plugins.OneSignal.getIds(function (ids) {
alert("ID : "+ids.userId + "\nToken "+ ids.pushToken);
});
});
}
document.addEventListener("app.Ready", register_event_handlers, false);
})();
<!DOCTYPE html>
<html>
<!--
* Please see the included README.md file for license terms and conditions.
-->
<head>
<title>Blank Cordova Mobile App Project Template (Lite)</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<!-- see http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/quick-tip-dont-forget-the-viewport-meta-tag -->
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<script src="cordova.js"></script> <!-- phantom library, needed for Cordova api calls, added during build -->
<script src="js/app.js"></script> <!-- recommended location of your JavaScript code relative to other JS files -->
<script src="xdk/init-dev.js"></script> <!-- normalizes device and document ready events, see README for details -->
<script src="js/jquery.js"></script> <!-- jquery -->
</head>
<body>
<div id="read"></div>
<!-- cordova-plugin-statusbar Yes -->
<!-- cordova-plugin-device Yes -->
<!-- cordova-plugin-splashscreen Yes -->
<!-- onesignal-cordova-plugin-pgb-compat Yes-->
<!-- com.google.playservices Yes -->
<!-- Minimum Android API 14 -->
<!-- Target Android API 19 -->
<p>Hello, Cordova!</p>
<button id="btn_push"> aperte aqui </button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment