Skip to content

Instantly share code, notes, and snippets.

@themodernpk
Created June 28, 2018 07:59
Show Gist options
  • Save themodernpk/d252b9f715994b82d2663b5bb2328a66 to your computer and use it in GitHub Desktop.
Save themodernpk/d252b9f715994b82d2663b5bb2328a66 to your computer and use it in GitHub Desktop.
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async=""></script>
<script>
var OneSignal_player_id;
var OneSignal = window.OneSignal || [];
OneSignal.push(["init", {
appId: "<?php echo env('ONESIGNAL_APP_ID') ?>",
autoRegister: true,
notifyButton: {
enable: true
}
}]);
OneSignal.push(function() {
OneSignal.showHttpPrompt();
});
OneSignal.push(function() {
OneSignal.getUserId(function(userId)
{
console.log("one signal-->", userId);
OneSignal.sendTag('{{env('APP_SHORT_NAME')}}-user-id', {{\Auth::user()->id}});
OneSignal_player_id = userId;
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment