EddyVerbruggen / nativescript-local-notifications

:mailbox: NativeScript plugin to easily schedule local notifications
MIT License
162 stars 57 forks source link

generated id prevents my id from being stored #143

Closed lord-zeus closed 5 years ago

lord-zeus commented 5 years ago

generated id is preventing me from using my own id and each time I give the id a value it just generates its own id and its really a problem any help please

EddyVerbruggen commented 5 years ago

Please elaborate. A code sample would be nice.

lord-zeus commented 5 years ago

let notification_id = 8248d304-d1ba-4665-8c22-46c2f0201bf9 LocalNotifications.schedule([{ id: notification_id, title: 'The title', body: 'Recurs every minute until cancelled', ticker: 'The ticker', color: new Color("red"), badge: 1, groupedMessages:["The first", "Second", "Keep going", "one more..", "OK Stop"], //android only groupSummary:"Summary of the grouped messages above", //android only ongoing: true, // makes the notification ongoing (Android only) icon: 'res://heart', image: "https://cdn-images-1.medium.com/max/1200/1*c3cQvYJrVezv_Az0CoDcbA.jpeg", thumbnail: true, interval: 'minute', channel: 'My Channel', // default: 'Channel' sound: "customsound-ios.wav", // falls back to the default sound on Android at: new Date(new Date().getTime() + (10 * 1000)) // 10 seconds from now }]).then( function() { console.log("Notification scheduled"); }, function(error) { console.log("scheduling error: " + error); } )

it just keeps replacing my id with the generated one

EddyVerbruggen commented 5 years ago

iOS/Android/both? And I guess notification_id is a string?

lord-zeus commented 5 years ago

I'm testing for Android

lord-zeus commented 5 years ago

iOS/Android/both? And I guess notification_id is a string?

yes it is a string

EddyVerbruggen commented 5 years ago

According to this code I think you should use a number instead:

https://github.com/EddyVerbruggen/nativescript-local-notifications/blob/1e7a8766a0caf30abc88238060372ad2f36de8c4/src/local-notifications-common.ts#L286-L295

lord-zeus commented 5 years ago

According to this code I think you should use a number instead:

nativescript-local-notifications/src/local-notifications-common.ts Lines 286 to 295 in 1e7a876 protected static ensureID(opts: ScheduleOptions): number { const id = opts.id;

if (typeof id === "number") { return id; } else { // We need unique IDs in all notifications to be able to persist them without overwriting one another: return opts.id = LocalNotificationsCommon.generateNotificationID(); } }

is there a way to make it use strings since its just to keep the uniqueness and my ids are unique

EddyVerbruggen commented 5 years ago

AFAIK on Android the id must be an int. I'm sure you can think of a way of making unique numbers.