(无效)更新:-ios10中cordova本地通知的方法不起作用
计划和取消工作正常,但下载完成后更新通知对我来说不起作用。插件中编写的代码是在我不熟悉的目标C中。任何人对此问题的帮助都将不胜感激 错误:由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[UNNotificationRequest userInfo]:未识别的选择器发送到实例0x174030f40 我只是把相关的代码和文件名放在这里。请仔细阅读,并让我知道为什么它不工作。完整的参考,你可以去下面的插件链接 插件: File:File.service.js//调用插件的更新功能(无效)更新:-ios10中cordova本地通知的方法不起作用,cordova,cordova-plugins,ios10,uilocalnotification,Cordova,Cordova Plugins,Ios10,Uilocalnotification,计划和取消工作正常,但下载完成后更新通知对我来说不起作用。插件中编写的代码是在我不熟悉的目标C中。任何人对此问题的帮助都将不胜感激 错误:由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[UNNotificationRequest userInfo]:未识别的选择器发送到实例0x174030f40 我只是把相关的代码和文件名放在这里。请仔细阅读,并让我知道为什么它不工作。完整的参考,你可以去下面的插件链接 插件: File:File.servic
window.cordova.plugins.notification.local.update({
id: optionsId,
title: attachmentObject.Name,
text: 'Download completed successfully.'/*,
icon: 'res://icon.png'
,smallIcon:'res://icon.png'*/
},function (result) {
console.log('from local notification update ' + result);
// coming Null
});
文件:APPLocalNotification.h
#import <Foundation/Foundation.h>
#import <Cordova/CDVPlugin.h>
@import UserNotifications;
@interface APPLocalNotification : CDVPlugin <UNUserNotificationCenterDelegate>
// Execute all queued events
- (void) deviceready:(CDVInvokedUrlCommand*)command;
// Inform if the app has the permission to show
notifications
- (void) hasPermission:(CDVInvokedUrlCommand*)command;
// Register permission to show notifications
- (void) registerPermission:
(CDVInvokedUrlCommand*)command;
// Schedule set of notifications
- (void) schedule:(CDVInvokedUrlCommand*)command;
// Update set of notifications
- (void) update:(CDVInvokedUrlCommand*)command;
// Cancel set of notifications
- (void) cancel:(CDVInvokedUrlCommand*)command;
// Cancel all notifications
- (void) cancelAll:(CDVInvokedUrlCommand*)command;
// Clear set of notifications
- (void) clear:(CDVInvokedUrlCommand*)command;
// Clear all notifications
- (void) clearAll:(CDVInvokedUrlCommand*)command;
// If a notification with an ID is present
- (void) isPresent:(CDVInvokedUrlCommand*)command;
// If a notification with an ID is scheduled
- (void) isScheduled:(CDVInvokedUrlCommand*)command;
// If a notification with an ID is triggered
- (void) isTriggered:(CDVInvokedUrlCommand*)command;
// List all ids from all local notifications
- (void) getAllIds:(CDVInvokedUrlCommand*)command;
// List all ids from all pending notifications
- (void) getScheduledIds:(CDVInvokedUrlCommand*)command;
// List all ids from all triggered notifications
- (void) getTriggeredIds:(CDVInvokedUrlCommand*)command;
// Propertys for given local notification
- (void) getSingle:(CDVInvokedUrlCommand*)command;
// Propertya for given scheduled notification
- (void) getSingleScheduled:
(CDVInvokedUrlCommand*)command;
// Propertys for given triggered notification
- (void) getSingleTriggered:
(CDVInvokedUrlCommand*)command;
// Property list for given local notifications
- (void) getAll:(CDVInvokedUrlCommand*)command;
// Property list for given scheduled notifications
- (void) getScheduled:(CDVInvokedUrlCommand*)command;
// Property list for given triggered notifications
- (void) getTriggered:(CDVInvokedUrlCommand*)command;
@end
部分代码在(void)update方法中注释,该方法假定在ios10中更新通知。取消注释导致应用程序崩溃,但出现错误
#import "APPLocalNotification.h"
#import "APPLocalNotificationOptions.h"
#import "UNUserNotificationCenter+APPLocalNotification.h"
#import "UNNotificationRequest+APPLocalNotification.h"
#import "UNMutableNotificationContent+APPLocalNotification.h"
#import "APPLocalNotificationOptions.ios9.h"
#import "UIApplication+APPLocalNotification.ios9.h"
#import "UILocalNotification+APPLocalNotification.ios9.h"
- (void) update:(CDVInvokedUrlCommand*)command
{
NSArray* notifications = command.arguments;
[self.commandDelegate runInBackground:^{
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0")) {
NSLog(@" Ramesh Entered : IOS 10");
for (NSDictionary* options in notifications) {
NSNumber* id = [options objectForKey:@"id"];
UNNotificationRequest* notification;
notification = [self.center getNotificationWithId:id];
NSLog(@" Ramesh getnotification : IOS 10 ");
NSLog(@"%@",notification);
if (!notification)
continue;
// [self updateNotification:[notification copy] withOptions:options];
// [self fireEvent:@"update" notification:notification];
// if (notifications.count > 1) {
// [NSThread sleepForTimeInterval:0.01];
// }
}
} else {
for (NSDictionary* options in notifications) {
NSNumber* id = [options objectForKey:@"id"];
UILocalNotification* notification;
notification = [self.app localNotificationWithId:id];
if (!notification)
continue;
[self updateLocalNotification:[notification copy]
withOptions:options];
[self fireEvent:@"update" localnotification:notification];
if (notifications.count > 1) {
[NSThread sleepForTimeInterval:0.01];
}
}
}
[self execCallback:command];
}];
}
- (void) updateNotification:(UILocalNotification*)notification
withOptions:(NSDictionary*)newOptions
{
NSMutableDictionary* options = [notification.userInfo mutableCopy];
[options addEntriesFromDictionary:newOptions];
[options setObject:[NSDate date] forKey:@"updatedAt"];
// notification = [[UILocalNotification alloc]
// initWithOptions:options];
// [self scheduleLocalNotification:notification];
}