出于修改通知的目的,我们使用了通知服务扩展,但我无法在我的 xcode 控制台中找到一些日志。
(void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
self.contentHandler = contentHandler;
self.bestAttemptContent = [request.content mutableCopy];
// Modify the notification content here...
NSLog(@"tesrrrr");(Missing in console)
self.bestAttemptContent.title = [NSString stringWithFormat:self.getfuction, self.bestAttemptContent.title];
self.bestAttemptContent.body = [NSString stringWithFormat:@"%@[ body added Manually ", self.bestAttemptContent.body];
self.contentHandler(self.bestAttemptContent);
-(NSString*)getfunction {
NSLog(@"xyz");
NSURL *url = [NSURL URLWithString:@"http://jsonplaceholder.typicode.com/posts/1"];
NSData *data = [NSData dataWithContentsOfURL:url];
NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"ret=%@", ret);(Still Missing in console)
return ret ;
}
Nslog 不会出现在 Xcode Console 中。
放入 Appdelegate.m 的相同代码工作正常