Gathering detailed insights and metrics for nativescript-ssi-local-notifications
Gathering detailed insights and metrics for nativescript-ssi-local-notifications
Gathering detailed insights and metrics for nativescript-ssi-local-notifications
Gathering detailed insights and metrics for nativescript-ssi-local-notifications
📫 NativeScript plugin to easily schedule local notifications
npm install nativescript-ssi-local-notifications
Typescript
Module System
Node Version
NPM Version
TypeScript (38.98%)
Java (32%)
Objective-C (22.44%)
Vue (3.22%)
HTML (1.4%)
Shell (1.02%)
CSS (0.45%)
JavaScript (0.25%)
SCSS (0.23%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
215 Commits
1 Watchers
1 Branches
Updated on Sep 21, 2023
Latest Version
3.2.1
Package Id
nativescript-ssi-local-notifications@3.2.1
Unpacked Size
433.67 kB
Size
106.67 kB
File Count
17
NPM Version
6.4.1
Node Version
8.11.1
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
No dependencies detected.
The Local Notifications plugin allows your app to show notifications when the app is not running. Just like remote push notifications, but a few orders of magnitude easier to set up.
From the command prompt go to your app's root folder and execute:
1tns plugin add nativescript-ssi-local-notifications
And do yourself a favor by adding TypeScript support to your nativeScript app:
1tns install typescript
Now you can import the plugin as an object into your .ts
file as follows:
1import * as LocalNotifications from "nativescript-ssi-local-notifications"; 2 3// then use it as: 4LocalNotifications.hasPermission()
If you want a quickstart, clone our demo app.
This plugin is part of the plugin showcase app I built using Angular.
On iOS you need to ask permission to schedule a notification.
You can have the schedule
funtion do that for you automatically (the notification will be scheduled in case the user granted permission),
or you can manually invoke requestPermission
if that's your thing.
You can pass several options to this function, everything is optional:
option | description |
---|---|
id | A number so you can easily distinguish your notifications. Default 0. |
title | The title which is shown in the statusbar. Default empty. |
body | The text below the title. Default empty. |
groupedMessages | An array of atmost 5 messages that would be displayed using android's notification inboxStyle. Note: The array would be trimed from the top if the messages exceed five. Default not set |
groupSummary | An inboxStyle notification summary. Default empty |
ticker | On Android you can show a different text in the statusbar, instead of the body . Default not set, so body is used. |
at | A JavaScript Date object indicating when the notification should be shown. Default 'now'. |
badge | On iOS (and some Android devices) you see a number on top of the app icon. On most Android devices you'll see this number in the notification center. Default not set (0). |
sound | Notification sound. For custom notification sound, copy sound file in App_Resources/iOS (iOS) and App_Resources/Android/raw (Android). Set this to "default" (or do not set at all) in order to use default OS sound. Set this to null to suppress sound. |
interval | Set to one of second minute hour day week month quarter year if you want a recurring notification. |
smallIcon | On Android you can set a custom icon in the system tray. Pass in 'res://filename' (without the extension) which lives in App_Resouces/Android/drawable folders. If not passed, we look for a file named 'ic_stat_notify.png' in the App_Resources/Android/drawable folders. Default: the app icon. |
largeIcon | Same as smallIcon , but this one is shown when you expand the notification center. The optional file we look for is not 'ic_stat_notify.png' but 'ic_notify.png'. |
ongoing | Default is (false ). Set whether this is an ongoing notification. Ongoing notifications cannot be dismissed by the user, so your application must take care of canceling them.(Android Only) |
Note that after a reboot the smallIcon
and largeIcon
are not restored but fall back to the default (app icon). This is a known issue and can be fixed in a future version.
1 LocalNotifications.schedule([{ 2 id: 1, 3 title: 'The title', 4 body: 'Recurs every minute until cancelled', 5 ticker: 'The ticker', 6 badge: 1, 7 groupedMessages:["The first", "Second", "Keep going", "one more..", "OK Stop"], //android only 8 groupSummary:"Summary of the grouped messages above", //android only 9 ongoing: true, // makes the notification ongoing (Android only) 10 smallIcon: 'res://heart', 11 interval: 'minute', 12 sound: require("application").ios ? "customsound-ios.wav" : "customsound-android", // can be also `null`, "default" 13 at: new Date(new Date().getTime() + (10 * 1000)) // 10 seconds from now 14 }]).then( 15 function() { 16 console.log("Notification scheduled"); 17 }, 18 function(error) { 19 console.log("scheduling error: " + error); 20 } 21 )
Background information: Local notifications may fail silently if you don't provide the notification icons in the correct dimensions. They may do work perfectly fine on one device but fail on the other. That's because android might fallback to your xxxhdpi launcher icon which is too big. This type of error is noticeable in logcat:
!!! FAILED BINDER TRANSACTION !!! (parcel size = 1435376)
Android API Guides → Status Bar Icons
Unfortunately it seems like there's no official guide for these. Anyways there's a dimen that's telling us the dp size which we can translate to the following spec:
Density qualifier | px | dpi |
---|---|---|
ldpi | 48 x 48 | 120 |
mdpi | 64 x 64 | 160 |
hdpi | 96 x 96 | 240 |
xhdpi | 128 x 128 | 320 |
xxhdpi | 192 x 192 | 480 |
Don't include xxxhdpi
xxxhdpi: Extra-extra-extra-high-density uses (launcher icon only, see the note in Supporting Multiple Screens); approximately 640dpi. Added in API Level 18
Source: Density Qualifier Docs
Tapping a notification in the notification center will launch your app. But what if you scheduled two notifications and you want to know which one the user tapped?
Use this function to have a callback invoked when a notification was used to launch your app. Note that on iOS it will even be triggered when your app is in the foreground and a notification is received.
1 LocalNotifications.addOnMessageReceivedCallback( 2 function (notification) { 3 console.log("ID: " + notification.id); 4 console.log("Title: " + notification.title); 5 console.log("Body: " + notification.body); 6 } 7 ).then( 8 function() { 9 console.log("Listener added"); 10 } 11 )
If you want to know the ID's of all notifications which have been scheduled, do this:
Note that all functions have an error handler as well (see schedule
), but to keep things readable we won't repeat ourselves.
1 LocalNotifications.getScheduledIds().then( 2 function(ids) { 3 console.log("ID's: " + ids); 4 } 5 )
If you want to cancel a previously scheduled notification (and you know its ID), you can cancel it:
1 LocalNotifications.cancel(5 /* the ID */).then( 2 function(foundAndCanceled) { 3 if (foundAndCanceled) { 4 console.log("OK, it's gone!"); 5 } else { 6 console.log("No ID 5 was scheduled"); 7 } 8 } 9 )
If you just want to cancel all previously scheduled notifications, do this:
1 LocalNotifications.cancelAll();
On Android you don't need permission, but on iOS you do. Android will simply return true.
If the requestPermission
or schedule
function previously ran the user has already been prompted to grant permission.
If the user granted permission this function returns true
, but if he denied permission this function will return false
,
since an iOS can only request permission once. In which case the user needs to go to the iOS settings app and manually
enable permissions for your app.
1 LocalNotifications.requestPermission().then( 2 function(granted) { 3 console.log("Permission granted? " + granted); 4 } 5 )
On Android you don't need permission, but on iOS you do. Android will simply return true.
If the requestPermission
or schedule
functions previously ran you may want to check whether or not the user granted permission:
1 LocalNotifications.hasPermission().then( 2 function(granted) { 3 console.log("Permission granted? " + granted); 4 } 5 )
Let us know what you need by opening a Github issue.
We're thinking about adding support for things like:
No vulnerabilities found.
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
3 existing vulnerabilities detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More