Skip to content

Commit aac238a

Browse files
committed
SImplified main ionic and ionic/ngx builds
1 parent fcfb562 commit aac238a

File tree

11 files changed

+323
-102
lines changed

11 files changed

+323
-102
lines changed

ionic/FCM.js

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
1-
import { Subject } from 'rxjs';
2-
var FCMPluginOnIonic = (function () {
3-
function FCMPluginOnIonic() {
1+
import { Subject } from 'rxjs'
2+
3+
function FCMPluginOnIonic() {}
4+
FCMPluginOnIonic.prototype.clearAllNotifications = function () {
5+
return window.FCM.clearAllNotifications()
6+
}
7+
FCMPluginOnIonic.prototype.createNotificationChannel = function (channelConfig) {
8+
return window.FCM.createNotificationChannel(channelConfig)
9+
}
10+
FCMPluginOnIonic.prototype.getAPNSToken = function () {
11+
return window.FCM.getAPNSToken()
12+
}
13+
FCMPluginOnIonic.prototype.getInitialPushPayload = function () {
14+
return window.FCM.getInitialPushPayload()
15+
}
16+
FCMPluginOnIonic.prototype.getToken = function () {
17+
return window.FCM.getToken()
18+
}
19+
FCMPluginOnIonic.prototype.hasPermission = function () {
20+
return window.FCM.hasPermission()
21+
}
22+
FCMPluginOnIonic.prototype.onNotification = function (options) {
23+
var observable = new Subject()
24+
var handler = function (payload) {
25+
return observable.next(payload)
426
}
5-
FCMPluginOnIonic.prototype.clearAllNotifications = function () {
6-
return window.FCM.clearAllNotifications();
7-
};
8-
FCMPluginOnIonic.prototype.createNotificationChannel = function (channelConfig) {
9-
return window.FCM.createNotificationChannel(channelConfig);
10-
};
11-
FCMPluginOnIonic.prototype.getAPNSToken = function () {
12-
return window.FCM.getAPNSToken();
13-
};
14-
FCMPluginOnIonic.prototype.getInitialPushPayload = function () {
15-
return window.FCM.getInitialPushPayload();
16-
};
17-
FCMPluginOnIonic.prototype.getToken = function () {
18-
return window.FCM.getToken();
19-
};
20-
FCMPluginOnIonic.prototype.hasPermission = function () {
21-
return window.FCM.hasPermission();
22-
};
23-
FCMPluginOnIonic.prototype.onNotification = function (options) {
24-
var observable = new Subject();
25-
var handler = function (payload) { return observable.next(payload); };
26-
window.FCM.onNotification(handler, options);
27-
return observable;
28-
};
29-
FCMPluginOnIonic.prototype.onTokenRefresh = function (options) {
30-
var observable = new Subject();
31-
window.FCM.onTokenRefresh(function (token) { return observable.next(token); }, options);
32-
return observable;
33-
};
34-
FCMPluginOnIonic.prototype.requestPushPermission = function (options) {
35-
return window.FCM.requestPushPermission(options);
36-
};
37-
FCMPluginOnIonic.prototype.subscribeToTopic = function (topic) {
38-
return window.FCM.subscribeToTopic(topic);
39-
};
40-
FCMPluginOnIonic.prototype.unsubscribeFromTopic = function (topic) {
41-
return window.FCM.unsubscribeFromTopic(topic);
42-
};
43-
return FCMPluginOnIonic;
44-
}());
45-
export { FCMPluginOnIonic };
46-
export var FCM = new FCMPluginOnIonic();
27+
window.FCM.onNotification(handler, options)
28+
return observable
29+
}
30+
FCMPluginOnIonic.prototype.onTokenRefresh = function (options) {
31+
var observable = new Subject()
32+
window.FCM.onTokenRefresh(function (token) {
33+
return observable.next(token)
34+
}, options)
35+
return observable
36+
}
37+
FCMPluginOnIonic.prototype.requestPushPermission = function (options) {
38+
return window.FCM.requestPushPermission(options)
39+
}
40+
FCMPluginOnIonic.prototype.subscribeToTopic = function (topic) {
41+
return window.FCM.subscribeToTopic(topic)
42+
}
43+
FCMPluginOnIonic.prototype.unsubscribeFromTopic = function (topic) {
44+
return window.FCM.unsubscribeFromTopic(topic)
45+
}
46+
47+
export { FCMPluginOnIonic }
48+
export var FCM = new FCMPluginOnIonic()

ionic/ngx/FCM.d.ts

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
import { FCMPluginOnIonic } from '../FCM';
2-
export declare class FCM extends FCMPluginOnIonic {
1+
import { Observable } from 'rxjs';
2+
import type { IChannelConfiguration } from '../../www/IChannelConfiguration';
3+
import type { INotificationPayload } from '../../www/INotificationPayload';
4+
import type { IRequestPushPermissionOptions } from '../../www/IRequestPushPermissionOptions';
5+
/**
6+
* @name FCM
7+
* @description
8+
* Easy plug&play push notification for Google Firebase FCM.
9+
*
10+
* @interfaces
11+
* INotificationPayload
12+
* IChannelConfiguration
13+
* IRequestPushPermissionOptions
14+
*/
15+
export declare class FCM {
316
static pluginName: string;
417
static plugin: string;
518
static pluginRef: string;
@@ -11,4 +24,90 @@ export declare class FCM extends FCMPluginOnIonic {
1124
static getPluginRef: () => string;
1225
static getPluginInstallName: () => string;
1326
static getSupportedPlatforms: () => string[];
27+
/**
28+
* Removes existing push notifications from the notifications center
29+
*
30+
* @returns {Promise<void>} Async call to native implementation
31+
*/
32+
clearAllNotifications(): Promise<void>;
33+
/**
34+
* For Android, some notification properties are only defined programmatically.
35+
* Channel can define the default behavior for notifications on Android 8.0+.
36+
* Once a channel is created, it stays unchangeable until the user uninstalls the app.
37+
*
38+
* @param {IChannelConfiguration} channelConfig The parmeters of the new channel
39+
*
40+
* @returns {Promise<void>} Async call to native implementation
41+
*/
42+
createNotificationChannel(channelConfig: IChannelConfiguration): Promise<void>;
43+
/**
44+
* Gets ios device's current APNS token
45+
*
46+
* @returns {Promise<string>} Returns a Promise that resolves with the APNS token
47+
*/
48+
getAPNSToken(): Promise<string>;
49+
/**
50+
* Retrieves the message that, on tap, opened the app
51+
*
52+
* @private
53+
*
54+
* @returns {Promise<INotificationPayload | null>} Async call to native implementation
55+
*/
56+
getInitialPushPayload(): Promise<INotificationPayload | null>;
57+
/**
58+
* Gets device's current registration id
59+
*
60+
* @returns {Promise<string>} Returns a Promise that resolves with the registration id token
61+
*/
62+
getToken(): Promise<string>;
63+
/**
64+
* Checking for permissions on iOS. On android, it always returns `true`.
65+
*
66+
* @returns {Promise<boolean | null>} Returns a Promise of:
67+
* - true: push was allowed (or platform is android)
68+
* - false: push will not be available
69+
* - null: still not answered, recommended checking again later.
70+
*/
71+
hasPermission(): Promise<boolean>;
72+
/**
73+
* Event firing when receiving new notifications
74+
*
75+
* @argument {{ once?: boolean }} options once defines if the listener is only trigger once
76+
* @returns {Observable<INotificationPayload>} An object to listen for notification data
77+
*/
78+
onNotification(options?: {
79+
once?: boolean;
80+
}): Observable<INotificationPayload>;
81+
/**
82+
* Event firing when receiving a new Firebase token
83+
*
84+
* @argument {{ once?: boolean }} options once defines if the listener is only trigger once
85+
* @returns {Observable<string>} An object to listen for the token
86+
*/
87+
onTokenRefresh(options?: {
88+
once?: boolean;
89+
}): Observable<string>;
90+
/**
91+
* Request push notification permission, alerting the user if it not have yet decided
92+
*
93+
* @param {IRequestPushPermissionOptions} options Options for push request
94+
* @returns {Promise<boolean>} Returns a Promise that resolves with the permission status
95+
*/
96+
requestPushPermission(options?: IRequestPushPermissionOptions): Promise<boolean>;
97+
/**
98+
* Subscribes you to a [topic](https://firebase.google.com/docs/notifications/android/console-topics)
99+
*
100+
* @param {string} topic Topic to be subscribed to
101+
*
102+
* @returns {Promise<void>} Async call to native implementation
103+
*/
104+
subscribeToTopic(topic: string): Promise<void>;
105+
/**
106+
* Unsubscribes you from a [topic](https://firebase.google.com/docs/notifications/android/console-topics)
107+
*
108+
* @param {string} topic Topic to be unsubscribed from
109+
*
110+
* @returns {Promise<void>} Async call to native implementation
111+
*/
112+
unsubscribeFromTopic(topic: string): Promise<void>;
14113
}

ionic/ngx/FCM.js

Lines changed: 61 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,62 @@
1-
import { __decorate, __extends } from "tslib";
2-
import { Injectable } from '@angular/core';
3-
import { IonicNativePlugin } from '@ionic-native/core';
4-
import { FCMPluginOnIonic } from '../FCM';
5-
var FCM = (function (_super) {
6-
__extends(FCM, _super);
7-
function FCM() {
8-
return _super !== null && _super.apply(this, arguments) || this;
1+
import { __decorate } from 'tslib'
2+
import { Injectable } from '@angular/core'
3+
import { Subject } from 'rxjs'
4+
import { IonicNativePlugin } from '@ionic-native/core'
5+
6+
function FCM() {}
7+
FCM.prototype.clearAllNotifications = function () {
8+
return window.FCM.clearAllNotifications()
9+
}
10+
FCM.prototype.createNotificationChannel = function (channelConfig) {
11+
return window.FCM.createNotificationChannel(channelConfig)
12+
}
13+
FCM.prototype.getAPNSToken = function () {
14+
return window.FCM.getAPNSToken()
15+
}
16+
FCM.prototype.getInitialPushPayload = function () {
17+
return window.FCM.getInitialPushPayload()
18+
}
19+
FCM.prototype.getToken = function () {
20+
return window.FCM.getToken()
21+
}
22+
FCM.prototype.hasPermission = function () {
23+
return window.FCM.hasPermission()
24+
}
25+
FCM.prototype.onNotification = function (options) {
26+
var observable = new Subject()
27+
var handler = function (payload) {
28+
return observable.next(payload)
929
}
10-
FCM.pluginName = 'FCM';
11-
FCM.plugin = 'cordova-plugin-fcm-with-dependecy-updated';
12-
FCM.pluginRef = 'FCM';
13-
FCM.repo = 'https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated';
14-
FCM.platforms = ['Android', 'iOS'];
15-
FCM.installed = IonicNativePlugin.installed;
16-
FCM.getPlugin = IonicNativePlugin.getPlugin;
17-
FCM.getPluginName = IonicNativePlugin.getPluginName;
18-
FCM.getPluginRef = IonicNativePlugin.getPluginRef;
19-
FCM.getPluginInstallName = IonicNativePlugin.getPluginInstallName;
20-
FCM.getSupportedPlatforms = IonicNativePlugin.getSupportedPlatforms;
21-
FCM = __decorate([
22-
Injectable()
23-
], FCM);
24-
return FCM;
25-
}(FCMPluginOnIonic));
26-
export { FCM };
30+
window.FCM.onNotification(handler, options)
31+
return observable
32+
}
33+
FCM.prototype.onTokenRefresh = function (options) {
34+
var observable = new Subject()
35+
window.FCM.onTokenRefresh(function (token) {
36+
return observable.next(token)
37+
}, options)
38+
return observable
39+
}
40+
FCM.prototype.requestPushPermission = function (options) {
41+
return window.FCM.requestPushPermission(options)
42+
}
43+
FCM.prototype.subscribeToTopic = function (topic) {
44+
return window.FCM.subscribeToTopic(topic)
45+
}
46+
FCM.prototype.unsubscribeFromTopic = function (topic) {
47+
return window.FCM.unsubscribeFromTopic(topic)
48+
}
49+
FCM.pluginName = 'FCM'
50+
FCM.plugin = 'cordova-plugin-fcm-with-dependecy-updated'
51+
FCM.pluginRef = 'FCM'
52+
FCM.repo = 'https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated'
53+
FCM.platforms = ['Android', 'iOS']
54+
FCM.installed = IonicNativePlugin.installed
55+
FCM.getPlugin = IonicNativePlugin.getPlugin
56+
FCM.getPluginName = IonicNativePlugin.getPluginName
57+
FCM.getPluginRef = IonicNativePlugin.getPluginRef
58+
FCM.getPluginInstallName = IonicNativePlugin.getPluginInstallName
59+
FCM.getSupportedPlatforms = IonicNativePlugin.getSupportedPlatforms
60+
FCM = __decorate([Injectable()], FCM)
61+
62+
export { FCM }

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"tslint-microsoft-contrib": "^6.2.0"
4444
},
4545
"dependencies": {
46-
"rxjs": "^6.5.5",
47-
"typescript": "^3.9.5"
46+
"typescript": "^3.9.6"
4847
}
4948
}

0 commit comments

Comments
 (0)