UserNotification(ローカル通知)にgifアニメーションを表示したいが、私はユーザー通知の画像しか表示できません。アニメーションは表示されません。 (UNNotificationRequest *)リクエスト withContentHandler:(無効(無効)didReceiveNotificationRequest - 私は、Objective-CのUserNotification ios 10
私のコード //通知をスケジュール
NSString *[email protected]"animatedContentExtension";
NSError *error;
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
content.title = [NSString localizedUserNotificationStringForKey:@"Test Notification:" arguments:nil];
content.body = [NSString localizedUserNotificationStringForKey:@"Hello there!It is a multimedia notification with animation!"
arguments:nil];
content.sound = [UNNotificationSound defaultSound];
UNNotificationAttachment *attachment;
NSURL *url = [[NSBundle mainBundle] URLForResource:@"bike" withExtension:@"png"];
attachment=[UNNotificationAttachment attachmentWithIdentifier:@"imageID"
URL: url
options:nil
error:&error];
[email protected][attachment];
content.categoryIdentifier=UNExtensionID;
content.badge = @([[UIApplication sharedApplication] applicationIconBadgeNumber] + 1);
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger
triggerWithTimeInterval:20.0f repeats:NO];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"FiveSecond"
content:content trigger:trigger];
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (!error) {
NSLog(@"add NotificationRequest succeeded!");
}
}];
// AppDelegate でこのコードでこれをやっています(^)(UNNotificationContent * contentToDeliver))のContentHandler {
UNNotificationAttachment *attachment;
NSError *error;
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
NSURL *url = [[NSBundle mainBundle] URLForResource:@"bike" withExtension:@"png"];
attachment=[UNNotificationAttachment attachmentWithIdentifier:@"imageID"
URL:url
options:nil
error:&error];
content=request.content.mutableCopy;
content.attachments= @[attachment];
`enter code here`contentHandler(content);
}
あなたは多分ドキュメントを読んでいますか? – holex
このようなgifイメージを提供する必要があります。NSURL * url = [[NSBundle mainBundle] URLForResource:@ "recording_animate" withExtension:@ "gif"]; @kishan – KAR