Skip to content

Instantly share code, notes, and snippets.

@stnc
Last active February 7, 2018 12:43
Show Gist options
  • Save stnc/19557b6b3e6beedf31412887bd156b2e to your computer and use it in GitHub Desktop.
Save stnc/19557b6b3e6beedf31412887bd156b2e to your computer and use it in GitHub Desktop.
Onesignal php api türkçe
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async></script>
<script>
window.OneSignal = window.OneSignal || [];
// Do NOT call init() twice
// OneSignal.setDefaultTitle("My Title");
OneSignal.push(["init", {
autoRegister: false,
persistNotification:true,
/* Your other init options here */
appId: "<?php echo $AppID?>",//buraya app den aldığınız kodu ekleyin.
welcomeNotification: {
/* These prompt options values configure both the HTTP prompt and the HTTP popup. */
/* actionMessage limited to 90 characters */
title: "Web siteniz Haber bilgilendirme",
/* acceptButtonText limited to 15 characters */
message: "Haber bilgilerinizden her yerde anında haberiniz olacaktır.",
url:"",
/* cancelButtonText limited to 15 characters */
},
promptOptions: {
/* These prompt options values configure both the HTTP prompt and the HTTP popup. */
/* actionMessage limited to 90 characters */
actionMessage: "Sitedeki yeni içeriklere abone olmak ister misiniz ?",
/* acceptButtonText limited to 15 characters */
acceptButtonText: "İstiyorum",
/* cancelButtonText limited to 15 characters */
cancelButtonText: "Hayır"
},
notifyButton: {
enable: true, /* Required to use the notify button */
size: 'small', /* One of 'small', 'medium', or 'large' */
theme: 'default', /* One of 'default' (red-white) or 'inverse" (white-red) */
position: 'bottom-left', /* Either 'bottom-left' or 'bottom-right' */
offset: {
bottom: '0px',
left: '0px', /* Only applied if bottom-left */
right: '0px' /* Only applied if bottom-right */
},
prenotify: true, /* Show an icon with 1 unread message for first-time site visitors */
showCredit: true, /* Hide the OneSignal logo */
text: {
'tip.state.unsubscribed': 'Haber bilgilerimden haberim olsun istemiyorum.',
'tip.state.subscribed': "Haber bilgilerimden anında haberim olsun istiyorum.",
'tip.state.blocked': "Bilgilendirilmeyi engellemişsiniz.",
'message.prenotify': 'Haber bilgilerinizi almak için tıklayın.',
'message.action.subscribed': "Takip ettiğiniz için teşekkür ederiz.",
'message.action.resubscribed': "Haber bildirimlerine abone oldunuz.",
'message.action.unsubscribed': "Tekrar Haber bildirimi almayacaksınız.",
'dialog.main.title': 'Haber Bildirimlerini Yönet',
'dialog.main.button.subscribe': 'Haber bilgilerine abone ol',
'dialog.main.button.unsubscribe': 'Haber bilgileri aboneliğinden çık',
'dialog.blocked.title': 'Haber Bildirimlerini Engellemeyi Kaldır',
'dialog.blocked.message': "Haber Bildirimine izin vermek için şu talimatları uygulayın:"
}
}
}]);
</script>
<script>
function subscribe() {
// OneSignal.push(["registerForPushNotifications"]);
OneSignal.push(["registerForPushNotifications"]);
event.preventDefault();
}
function unsubscribe() {
OneSignal.setSubscription(true);
}
var OneSignal = OneSignal || [];
OneSignal.push(function () {
OneSignal.on('subscriptionChange', function (isSubscribed) {
console.log("The user's subscription state is now:", isSubscribed);
OneSignal.sendTag("user_id",10, function(tagsSent)
//"user_id",10, kısmına mysql de bulunana user id yi de atayabilirsiniz
{
console.log("Tags have finished sending!");
}
);
});
var isPushSupported = OneSignal.isPushNotificationsSupported();
if (isPushSupported) {
// Push notifications are supported
OneSignal.isPushNotificationsEnabled().then(function (isEnabled) {
if (isEnabled) {
console.log("Push notifications are enabled!");
} else {
OneSignal.showHttpPrompt();
console.log("Push notifications are not enabled yet.");
}
});
} else {
console.log("Push notifications are not supported.");
}
})
;
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment