Skip to content

Commit 1e82bec

Browse files
#25 Incorrect package.json and d.ts to use as node module.
1 parent 598f5c2 commit 1e82bec

File tree

3 files changed

+113
-112
lines changed

3 files changed

+113
-112
lines changed

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ And do yourself a favor by adding TypeScript support to your nativeScript app:
1818
tns install typescript
1919
```
2020
21-
Then open `references.d.ts` in the root of your project and add this line to get autocompletion and type-checking for this plugin:
22-
23-
```
24-
/// <reference path="./node_modules/nativescript-local-notifications/local-notifications.d.ts" />
25-
```
26-
2721
Now you can import the plugin as an object into your `.ts` file as follows:
2822
2923
```js

local-notifications.d.ts

Lines changed: 111 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,123 @@
1-
declare module "nativescript-local-notifications" {
1+
declare namespace localNotifications {
22

33
/**
44
* The options object passed into the schedule function.
55
*/
66
export interface ScheduleOptions {
7-
/**
8-
* A number so you can easily distinguish your notifications.
9-
* Default 0.
10-
*/
11-
id?: number;
12-
13-
/**
14-
* The title which is shown in the statusbar.
15-
* Default empty.
16-
*/
17-
title?: string;
18-
19-
/**
20-
* The text below the title.
21-
* Default empty.
22-
*/
23-
body?: string;
24-
25-
/**
26-
* On Android you can show a different text in the statusbar, instead of the 'body'.
27-
* Default not set, so `body` is used.
28-
*/
29-
ticker?: string;
30-
31-
/**
32-
* A JavaScript Date object indicating when the notification should be shown.
33-
* Default 'now'.
34-
*/
35-
at?: Date;
36-
37-
/**
38-
* 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.
39-
* Default not set (0).
40-
*/
41-
badge?: number;
42-
43-
/**
44-
* Currently this is only used on Android where you can set this to 'null' to suppress the sound.
45-
* Default 'the default notification sound'.
46-
*/
47-
sound?: string;
48-
49-
/**
50-
* One of second|minute|hour|day|week|month|quarter|year
51-
*/
52-
interval?: string; // TODO add better TS support
7+
/**
8+
* A number so you can easily distinguish your notifications.
9+
* Default 0.
10+
*/
11+
id?: number;
12+
13+
/**
14+
* The title which is shown in the statusbar.
15+
* Default empty.
16+
*/
17+
title?: string;
18+
19+
/**
20+
* The text below the title.
21+
* Default empty.
22+
*/
23+
body?: string;
24+
25+
/**
26+
* On Android you can show a different text in the statusbar, instead of the 'body'.
27+
* Default not set, so `body` is used.
28+
*/
29+
ticker?: string;
30+
31+
/**
32+
* A JavaScript Date object indicating when the notification should be shown.
33+
* Default 'now'.
34+
*/
35+
at?: Date;
36+
37+
/**
38+
* 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.
39+
* Default not set (0).
40+
*/
41+
badge?: number;
42+
43+
/**
44+
* Currently this is only used on Android where you can set this to 'null' to suppress the sound.
45+
* Default 'the default notification sound'.
46+
*/
47+
sound?: string;
48+
49+
/**
50+
* One of second|minute|hour|day|week|month|quarter|year
51+
*/
52+
interval?: string; // TODO add better TS support
5353
}
5454

5555
export interface ReceivedNotification {
56-
id: number;
57-
title?: string;
58-
body?: string;
56+
id: number;
57+
title?: string;
58+
body?: string;
5959
}
6060

61-
/**
62-
* On iOS you need to ask permission to schedule a notification.
63-
* You can have the `schedule` funtion do that for you automatically
64-
* (the notification will be scheduled in case the user granted permission),
65-
* or you can manually invoke `requestPermission` if that's your thing.
66-
*/
67-
export function schedule(options: ScheduleOptions[]): Promise<any>;
68-
69-
/**
70-
* Tapping a notification in the notification center will launch your app.
71-
* But what if you scheduled two notifications and you want to know which one the user tapped?
72-
*
73-
* Use this function to have a callback invoked when a notification was used to launch your app.
74-
* Note that on iOS it will even be triggered when your app is in the foreground and a notification is received.
75-
*/
76-
export function addOnMessageReceivedCallback(onReceived: (data: ReceivedNotification) => void): Promise<any>;
77-
78-
/**
79-
* Use when you want to know the id's of all notifications which have been scheduled.
80-
*/
81-
export function getScheduledIds(): Promise<any>;
82-
83-
/**
84-
* Cancels the 'id' passed in.
85-
* On iOS returns whether or not it was found (and cancelled).
86-
* On Android we always return true currently.
87-
*/
88-
export function cancel(id: number): Promise<boolean>;
61+
interface LocalNotifications {
62+
/**
63+
* On iOS you need to ask permission to schedule a notification.
64+
* You can have the `schedule` funtion do that for you automatically
65+
* (the notification will be scheduled in case the user granted permission),
66+
* or you can manually invoke `requestPermission` if that's your thing.
67+
*/
68+
schedule(options: ScheduleOptions[]): Promise<any>;
69+
70+
/**
71+
* Tapping a notification in the notification center will launch your app.
72+
* But what if you scheduled two notifications and you want to know which one the user tapped?
73+
*
74+
* Use this function to have a callback invoked when a notification was used to launch your app.
75+
* Note that on iOS it will even be triggered when your app is in the foreground and a notification is received.
76+
*/
77+
addOnMessageReceivedCallback(onReceived: (data: ReceivedNotification) => void): Promise<any>;
78+
79+
/**
80+
* Use when you want to know the id's of all notifications which have been scheduled.
81+
*/
82+
getScheduledIds(): Promise<any>;
83+
84+
/**
85+
* Cancels the 'id' passed in.
86+
* On iOS returns whether or not it was found (and cancelled).
87+
* On Android we always return true currently.
88+
*/
89+
cancel(id: number): Promise<boolean>;
90+
91+
/**
92+
* Use when you just want to cancel all previously scheduled notifications.
93+
*/
94+
cancelAll(): Promise<any>;
95+
96+
/**
97+
* On Android you don't need permission, but on iOS you do.
98+
* Android will simply return true.
99+
*
100+
* If the 'requestPermission' or 'schedule' functions previously ran
101+
* you may want to check whether or not the user granted permission.
102+
*/
103+
hasPermission(): Promise<boolean>;
104+
105+
/**
106+
* On Android you don't need permission, but on iOS you do.
107+
* Android will simply return true.
108+
*
109+
* If the 'requestPermission' or 'schedule' function previously ran
110+
* the user has already been prompted to grant permission.
111+
*
112+
* If the user granted permission this function returns true,
113+
* but if he denied permission this function will return false
114+
* since an iOS can only request permission once. In which case the user needs
115+
* to go to the iOS settings app and manually enable permissions for your app.
116+
*/
117+
requestPermission(): Promise<boolean>;
118+
}
119+
}
89120

90-
/**
91-
* Use when you just want to cancel all previously scheduled notifications.
92-
*/
93-
export function cancelAll(): Promise<any>;
94121

95-
/**
96-
* On Android you don't need permission, but on iOS you do.
97-
* Android will simply return true.
98-
*
99-
* If the 'requestPermission' or 'schedule' functions previously ran
100-
* you may want to check whether or not the user granted permission.
101-
*/
102-
export function hasPermission(): Promise<boolean>;
103-
104-
/**
105-
* On Android you don't need permission, but on iOS you do.
106-
* Android will simply return true.
107-
*
108-
* If the 'requestPermission' or 'schedule' function previously ran
109-
* the user has already been prompted to grant permission.
110-
*
111-
* If the user granted permission this function returns true,
112-
* but if he denied permission this function will return false
113-
* since an iOS can only request permission once. In which case the user needs
114-
* to go to the iOS settings app and manually enable permissions for your app.
115-
*/
116-
export function requestPermission(): Promise<boolean>;
117-
}
122+
declare var localNotifications: localNotifications.LocalNotifications;
123+
export = localNotifications;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "nativescript-local-notifications",
3-
"version": "1.1.6",
3+
"version": "1.1.7",
44
"description": "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.",
55
"main" : "local-notifications.js",
6+
"typings": "local-notifications.d.ts",
67
"nativescript": {
78
"platforms": {
89
"android": "2.3.0",

0 commit comments

Comments
 (0)