当我启动``this.push.init(options);并在ios中使用本机离子推送的代码正常运行时它会征求用户的许可,并且可以正常工作,但是在android中什么也不会发生,因此请不要输入这些方法
this.push.hasPermission().then((res: any) => {
if (res.isEnabled) {
alert('have permission');
const options: PushOptions = {
android: {},
ios: {
alert: 'true',
badge: true,
sound: 'false'
},
windows: {},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
}
};
const pushObject: PushObject = this.push.init(options);
pushObject.on('notification').subscribe((notification: any) => {
alert(notification.message);
});
pushObject.on('registration').subscribe((registration: any) => console.log('Device registered', registration));
pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error));
} else {
alert('don`t have permission');
}
});
-
<plugin name="phonegap-plugin-push" spec="^2.0.0">
<variable name="SENDER_ID" value="32673134" />
</plugin>
<platform name="android">
<resource-file src="google-services.json" target="google-services.json" />
</platform>