I am trying to add image to notification in iOS module of LibGdx project for which i am required to add url for image in the UNNotificationAttachment and add this attachment to the notification center but while initalizing UNNotificationAttachment it only return 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