OneSignal / onesignal-node-api

OneSignal Node Client
Other
28 stars 12 forks source link

How to set title and subtitle? (APNS) #52

Closed iOSDevil closed 1 year ago

iOSDevil commented 1 year ago

How can we help?

Hi,

I'm able to send notifications to iOS using this: const configurationOnesignal = OneSignal.createConfiguration({ appKey: apiKey, });

const client = new OneSignal.DefaultApi(configurationOnesignal);

const notification = new OneSignal.Notification();

notification.contents = { en: "message" }

What I'd really like to do is replicate what can be done via the one signal website.. set a title, a subtitle and a message.

Is that possible? I've looked through all the docs and even the code so I'm thinking not..

Thanks in advance!

Code of Conduct

iOSDevil commented 1 year ago

nvm, I figured it out by observing the browser traffic.

async function sendAPNS(message, title, subtitle) { const notification = new OneSignal.Notification(); notification.include_player_ids = [ids]; notification.app_id = oneSignalAppIDPaid; notification.headings = { "en": title }, notification.subtitle = { "en": subtitle }, notification.contents = { en: message } console.log(notification); clientOneSignal.createNotification(notification); }