cordova push 和本地通知冲突
cordova push and local notification conflict
我创建了一个移动应用程序 (Ionic + Cordova)。已安装 Cordova Push Notifications, Cordova Local-Notification Plugin 但是当我收到推送通知或离开屏幕时,我会丢失所有本地通知。如果通过 isScheduled 函数检查它们,我得到 TRUE。如果我删除推送通知代码
var config = null;
if (ionic.Platform.isAndroid()) {
config = {
"senderID": "111111111111" // REPLACE THIS WITH YOURS FROM GCM CONSOLE - also in the project URL like: https://console.developers.google.com/project/434205989073
//"ecb": "window.onNotificationGCM"
}
} else if (ionic.Platform.isIOS()) {
config = {
"badge": "true",
"sound": "true",
"alert": "true"
}
}
$cordovaPush.register(config).then(function(result) {
// ** NOTE: Android regid result comes back in the pushNotificationReceived, only iOS returned here
if (ionic.Platform.isIOS()) {
$rootScope.regId = result;
scheduleNotifications.storeDeviceToken("ios");
}
}, function(err) {
navigator.notification.alert("Register error " + err);
});
它工作正常。这有什么问题吗?
我觉得你很好,因为我什至不能 运行 他们在一起。
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support
/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfo
VersionImpl;
Local Notification 正在安装 android.support.v4 作为与 Ionic 其余部分冲突的依赖项。
编辑:通过核对 platforms/android/libs 下的 v4.jar 文件修复。
这是一个解决方案 - 只需添加 "clearNotifications": false 到推送通知 init
var push = PushNotification.init({
"android": {
"senderID": "114273210157",
"clearNotifications": false
},
"ios": {"alert": "true", "badge": "true", "sound": "true"}
});
我创建了一个移动应用程序 (Ionic + Cordova)。已安装 Cordova Push Notifications, Cordova Local-Notification Plugin 但是当我收到推送通知或离开屏幕时,我会丢失所有本地通知。如果通过 isScheduled 函数检查它们,我得到 TRUE。如果我删除推送通知代码
var config = null;
if (ionic.Platform.isAndroid()) {
config = {
"senderID": "111111111111" // REPLACE THIS WITH YOURS FROM GCM CONSOLE - also in the project URL like: https://console.developers.google.com/project/434205989073
//"ecb": "window.onNotificationGCM"
}
} else if (ionic.Platform.isIOS()) {
config = {
"badge": "true",
"sound": "true",
"alert": "true"
}
}
$cordovaPush.register(config).then(function(result) {
// ** NOTE: Android regid result comes back in the pushNotificationReceived, only iOS returned here
if (ionic.Platform.isIOS()) {
$rootScope.regId = result;
scheduleNotifications.storeDeviceToken("ios");
}
}, function(err) {
navigator.notification.alert("Register error " + err);
});
它工作正常。这有什么问题吗?
我觉得你很好,因为我什至不能 运行 他们在一起。
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support
/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfo
VersionImpl;
Local Notification 正在安装 android.support.v4 作为与 Ionic 其余部分冲突的依赖项。
编辑:通过核对 platforms/android/libs 下的 v4.jar 文件修复。
这是一个解决方案 - 只需添加 "clearNotifications": false 到推送通知 init
var push = PushNotification.init({
"android": {
"senderID": "114273210157",
"clearNotifications": false
},
"ios": {"alert": "true", "badge": "true", "sound": "true"}
});