Last active
September 13, 2018 14:08
-
-
Save davorpeic/93605ccf42702e7b932c61b6bd6bcc46 to your computer and use it in GitHub Desktop.
OneSignal service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from "@angular/core"; | |
import * as application from 'application'; | |
let TnsOneSignal = require('nativescript-onesignal').TnsOneSignal; | |
@Injectable() | |
export class NotificationService { | |
constructor() {} | |
getUserIds():Promise<any> { | |
let p = new Promise((resolve, reject) => { | |
TnsOneSignal.IdsAvailable(function(userId,registrationId) { | |
if(userId != 'nil' || userId != "" || userId != undefined) { | |
console.log("trying to get IDS...", userId); | |
resolve(userId); | |
} | |
else { | |
reject('No IDs available'); | |
} | |
}); | |
}); | |
return p; | |
}; | |
// {mytag1: "value1", mytag2: "value2", mytag3: "value3"} | |
saveTags(tags){ | |
if(application.ios) { | |
TnsOneSignal.sendTags(tags); | |
} | |
if(application.android) { | |
com.onesignal.OneSignal.sendTags(JSON.stringify(tags)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, Have you configured
receivedCallback
/actionCallback
? I was unable to redirect when a button is clicked on notification. Hoping you can help here.