-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature(): Phonegap local notifications #1474
Changes from 7 commits
2f7a6fe
128c1da
a0a14b2
c6cfe75
c7fe8ad
c51390d
402e2e2
7430487
9ce7c3f
3ff0779
6fccbbb
a48ae95
e857c65
0329f28
ae4d89a
a2f606d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Cordova, CordovaInstance, Plugin, IonicNativePlugin, checkAvailability } from '@ionic-native/core'; | ||
|
||
declare var Notification: any; | ||
// can use a shorter name here, like PLNObject ? | ||
export class PLNObject { | ||
|
||
private _objectInstance: any; | ||
|
||
constructor(title: string, options: any) { | ||
if (checkAvailability('Notification') === true) { | ||
this._objectInstance = new Notification(title, options); | ||
} | ||
} | ||
|
||
@CordovaInstance({ sync: true }) | ||
close(): void { } | ||
|
||
} | ||
|
||
export interface LocalNotificationOptions { | ||
|
||
/** | ||
* Sets the direction of the notification. One of "auto", "ltr" or "rtl" | ||
*/ | ||
dir?: string; | ||
|
||
/** | ||
* Sets the language of the notification | ||
*/ | ||
lang?: string; | ||
|
||
/** | ||
* Sets the body of the notification | ||
*/ | ||
body?: string; | ||
|
||
/** | ||
* Sets the identifying tag of the notification | ||
*/ | ||
tag?: string; | ||
|
||
/** | ||
* Sets the icon of the notification | ||
*/ | ||
icon?: string; | ||
|
||
} | ||
|
||
/** | ||
* @name phonegap-local-notifications | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name needs to be |
||
* @description | ||
* This plugin does something | ||
* | ||
* @usage | ||
* ``` | ||
* import { PhonegapLocalNotifications } from '@ionic-native/phonegap-local-notifications'; | ||
* | ||
* | ||
* constructor(private localNotification: PhonegapLocalNotifications) { } | ||
* | ||
* ... | ||
* | ||
* this.localNotification.requestPermission().then( | ||
* (permission) => { | ||
* if (permission === ‘granted’) { | ||
* let notification = new Notification(“My title”, { | ||
* tag: ‘message1’, | ||
* body: “My body” | ||
* }); | ||
* } | ||
* } | ||
* ); | ||
* | ||
* ``` | ||
*/ | ||
@Plugin({ | ||
pluginName: 'Phonegap Loca Notifications', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got a typo here.. Loca -> Local |
||
plugin: 'phonegap-local-notifications', | ||
pluginRef: 'Notification', | ||
repo: 'https://github.com/phonegap/phonegap-plugin-local-notification', | ||
platforms: ['Android', 'iOS'] | ||
}) | ||
@Injectable() | ||
export class PhonegapLocalNotifications extends IonicNativePlugin { | ||
|
||
/** | ||
* A global object that lets you interact with the Notification API. | ||
* @param title {string} Title of the local notification. | ||
* @param Options {LocalNotificationOptions} An object containing optional property/value pairs. | ||
*/ | ||
@Cordova() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to remove this decorator because it will override the functionality you wrote |
||
create(title: string, options: any) { return new PLNObject(title, options); } | ||
/** | ||
* requests permission from the user to show a local notification. | ||
* @param {Promise<any>} | ||
*/ | ||
@Cordova() | ||
requestPermission(): Promise<any> { return; } | ||
|
||
/** | ||
* closes an open notification. | ||
*/ | ||
close(): void { } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the |
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment