You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello I wrote a wrapper for ionic native push plugin. But after the App is starts. It's get a error TypeError: plugin.constructor.getPluginRef is not a function.
Here is a code of my wrapper:
import { Injectable } from "@angular/core";
import {
Push, PushObject, PushOptions, EventResponse, NotificationEventResponse,
RegistrationEventResponse
} from '@ionic-native/push';
import { Events, ToastController, Platform, App, NavController } from "ionic-angular";
import { Device } from "ionic-native";
import { APP_CONFIG } from "../app/app.config";
/**
* Класс сервиса для управления PUSH уведомлениями
*/
@Injectable()
export class PushNotificationService {
register_token_url = '/api/methods/push.registerToken';
pushNotification: PushObject; //Notification's API
push_token = "";
messages_stack_id = []; //Messages stack
/**
* Constructor of class
*
*/
constructor(
public plt: Platform,
public toastCtrl: ToastController,
public appCtrl: App,
public httpRequestService: HttpRequestService,
public authService: AuthService,
public events: Events,
public push: Push
){
}
/**
* Initialization
*/
init()
{
let pushSenderID = APP_CONFIG.pushSenderID.toString();
if (pushSenderID.length) { //If we have sender id
const options: PushOptions = {
android: {
sound: true,
vibrate: true,
forceShow: false,
senderID: pushSenderID
},
ios: {
alert: true,
badge: true,
sound: true,
gcmSandbox: true,
senderID: pushSenderID
},
windows: {}
};
this.pushNotification = this.push.init(options);
//Check the rights
if (this.plt.is('ios') || this.plt.is('android')) {
this.pushNotification.hasPermission().then((isEnabled) => { //If we get push rights
if (!isEnabled){
this.showToast('No right to get push notify.');
}else{
console.log('We have PUSH permission!');
}
}).catch((reason) => {
this.showToast('No right to get push notify: ' + reason.toString()); //Here is a error
});
}
//Registration of token
this.pushNotification.on('registration').subscribe((data: RegistrationEventResponse) => {
this.onRegistrationToken(data);
});
//Get Notification
this.pushNotification.on('notification').subscribe((data: NotificationEventResponse) => {
this.onNotification(data);
});
//Get errors
this.pushNotification.on('error').subscribe((e: Error) => {
console.error(e.message);
this.showToast("PUSH Error: " + e.message);
});
}
}
}
Hello I wrote a wrapper for ionic native push plugin. But after the App is starts. It's get a error TypeError: plugin.constructor.getPluginRef is not a function.
Here is a code of my wrapper:
I got lastest installed packeges:
The text was updated successfully, but these errors were encountered: