【发布时间】:2020-12-12 12:44:54
【问题描述】:
我正在尝试将图像添加到 LibGdx 项目的 iOS 模块中的通知中,为此我需要在 UNNotificationAttachment 中添加图像的 url 并将此附件添加到通知中心,但在初始化 UNNotificationAttachment 时它只返回 null。
try {
System.out.println("Attachment TryEntered--------------->");
dir = NSFileManager.getDefaultManager().getURLsForDirectory(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask).first();
String tmpSubFolderName = NSProcessInfo.getSharedProcessInfo().getGloballyUniqueString();
NSURL tmpSubFolderURL = new NSURL().newURLByAppendingPathComponent(tmpSubFolderName,false);
java.lang.String imageURL = dir.getPath()+"/.Munchausen/en.munchausen.fingertipsandcompany.any/expansion/chapter/icon_a1.png";
System.out.println("Img url = "+imageURL);
NSDictionary<?,?> dictionary1 = new NSDictionary<>();
// attachment = new UNNotificationAttachment("image", new NSURL("https://png.pngtree.com/element_our/20190528/ourmid/pngtree-small-url-icon-opened-on-the-computer-image_1132275.jpg"),dictionary1 );
attachment = new UNNotificationAttachment("image", new NSURL(imageURL), dictionary1);
}catch (Exception e){
System.out.println("Attachment Error--------------->"+e);
}
-------------------------------- ----***********
SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
SLF4J: Defaulting to no-operation MDCAdapter implementation.
SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for further details.
Exception in thread "Thread-5" java.lang.RuntimeException: Objective-C initialization method returned nil
at org.robovm.objc.ObjCObject.initObject(ObjCObject.java:108)
at org.robovm.objc.ObjCObject.<init>(ObjCObject.java:97)
at org.robovm.apple.foundation.NSObject.<init>(NSObject.java:136)
at org.robovm.apple.usernotifications.UNNotificationAttachment.<init>(UNNotificationAttachment.java:54)
at org.robovm.apple.usernotifications.UNNotificationAttachment.<init>(UNNotificationAttachment.java:51)
at ua.gram.munhauzen.NotificationDelegate.scheduleNotification(NotificationDelegate.java:156)
at ua.gram.munhauzen.NotificationDelegate$1.invoke(NotificationDelegate.java:65)
at ua.gram.munhauzen.NotificationDelegate$1.invoke(NotificationDelegate.java:58)
at org.robovm.apple.usernotifications.UNUserNotificationCenter$$BlockMarshaler0.invoked(Unknown Source)
Unhandled exception (probably in a @Callback method called from native code): java/lang/RuntimeException
【问题讨论】:
标签: ios firebase push-notification libgdx apple-push-notifications