0

アプリで UNNotificationContentExtension を使用して、プッシュ通知用のカスタム UI を作成しています。通知ペイロードには、表示される画像の URL が含まれています。画像をダウンロードして一時的な場所に保存できます。問題は、画像が通知にまったく読み込まれていないことです。これは、すべての処理後に作成された UNNotificationAttachment です。

UNNotificationAttachment: 0x2820bfc30; identifier: DFEAC8A3-8B9E-4FFA-9CC4-3D7B3EE62F74, family: Image, URL: file:///private/var/mobile/Containers/Data/PluginKitPlugin/EF8FAE09-D295-485F-99FD-9BF2BE3628B4/tmp/CFNetworkDownload_bfL88G.tmp.jpg, type: public.jpeg, options: UNImageNotificationAttachmentOptions: 0x283bb6800

これは、添付オブジェクトを作成した後、didReceiveNotification で画像を読み込もうとした方法です。

dispatch_async(dispatch_get_main_queue(), ^{
                           self->notificationImageVw.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@",attachment.URL]];

                           [self->notificationImageVw setImage:[UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@",attachment.URL]]];


                           self->notificationImageVw.image = [UIImage imageWithContentsOfFile:[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",attachment.URL]]];

                       });

しかし、どれもうまくいきませんでした。私が間違っていることを教えてください。

4

0 に答える 0