-(void)addEventNotify:(NSDate )date title:(NSString )title
{
//生成事件数据库对象
EKEventStore *eventDB = [[EKEventStore alloc] init];
//申请事件类型权限
[eventDB requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError * _Nullable error) {
if (granted) { //授权是否成功
EKEvent *myEvent = [EKEvent eventWithEventStore:eventDB]; //创建一个日历事件
myEvent.title = title; //标题
myEvent.startDate = date; //开始date required
myEvent.endDate = date; //结束date required
[myEvent addAlarm:[EKAlarm alarmWithAbsoluteDate:date]]; //添加一个闹钟 optional
[myEvent setCalendar:[eventDB defaultCalendarForNewEvents]]; //添加calendar required
NSError *err;
[eventDB saveEvent:myEvent span:EKSpanThisEvent error:&err]; //保存
}
}];
}
上面是原生往日历中添加事件的方法,我现在想用native.js实现。请问一下 requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError * _Nullable error) 这个方法,用native.js怎么实现,因为他的参数是block,我不知道怎么写,求大神赐教
Thyme释念帅 (作者)
写插件,官方是这么给我说的
2016-11-28 16:54