Convert Objective C header file for RoboVM/Java (no bro-gen)

Anything libgdx related goes here!

Convert Objective C header file for RoboVM/Java (no bro-gen)

Postby zgintasz » Wed May 04, 2016 2:00 pm

Hi,

Bro-gen seems to not work for me, I get some stupid error and Google doesn't really provide anything useful.
Anyway, I have this simple header file:
Code: Select all
#import <Foundation/Foundation.h>

@interface OneSignal : NSObject

@property(nonatomic, readonly, copy) NSString* app_id;

extern NSString* const ONESIGNAL_VERSION;

typedef NS_ENUM(NSUInteger, ONE_S_LOG_LEVEL) {
    ONE_S_LL_NONE, ONE_S_LL_FATAL, ONE_S_LL_ERROR, ONE_S_LL_WARN, ONE_S_LL_INFO, ONE_S_LL_DEBUG, ONE_S_LL_VERBOSE
};

- (id)initWithLaunchOptions:(NSDictionary*)launchOptions autoRegister:(BOOL)autoRegister;
+ (void)setLogLevel:(ONE_S_LOG_LEVEL)logLevel visualLevel:(ONE_S_LOG_LEVEL)visualLogLevel;
- (void)sendTag:(NSString*)key value:(NSString*)value;
- (void)enableInAppAlertNotification:(BOOL)enable;
- (void)setSubscription:(BOOL)enable;

@end


I tried looking at other examples, but they all look nasty and unclear. Objective C itself looks nasty too. If anyone would be willing to provide a few examples of converting it by hand, I would appreciate it.
Thank you.


EDIT: I got it working with the help of some guy. Here are my binders file, just in case if someone ever needs it:
Code: Select all
package org.robovm.pods.onesignal;

import org.robovm.apple.foundation.NSDictionary;
import org.robovm.apple.foundation.NSObject;
import org.robovm.objc.ObjCRuntime;
import org.robovm.objc.annotation.Block;
import org.robovm.objc.annotation.Method;
import org.robovm.objc.annotation.NativeClass;
import org.robovm.objc.block.VoidBlock3;
import org.robovm.rt.bro.annotation.Library;
import org.robovm.rt.bro.ValuedEnum;
import org.robovm.apple.foundation.NSString;
import org.robovm.rt.bro.ptr.Ptr;
import org.robovm.objc.block.VoidBlock3;

@Library(Library.INTERNAL)
@NativeClass
public class OneSignal extends NSObject {

    static {
        ObjCRuntime.bind(OneSignal.class);
    }

    @Method(selector = "initWithLaunchOptions:appId:handleNotification:autoRegister:")
    public native OneSignal initWithLaunchOptions (NSDictionary<?, ?> launchOptions, NSString appId, @Block VoidBlock3<NSString, NSDictionary<?, ?>, Boolean> handleNotification, boolean autoRegister);

    @Method(selector = "setSubscription:")
    public native void setSubscription(boolean enable);

    @Method(selector = "enableInAppAlertNotification:")
    public native void enableInAppAlertNotification(boolean enable);

    @Method(selector = "sendTag:value:")
    public native void sendTag(NSString key, NSString value);

    @org.robovm.rt.bro.annotation.Marshaler(ValuedEnum.AsMachineSizedSIntMarshaler.class)
    public enum ONE_S_LOG_LEVEL implements ValuedEnum
    {
        ONE_S_LL_NONE(0), ONE_S_LL_FATAL(1), ONE_S_LL_ERROR(2), ONE_S_LL_WARN(3), ONE_S_LL_INFO(4), ONE_S_LL_DEBUG(5), ONE_S_LL_VERBOSE(6);

        private final int n;
        private ONE_S_LOG_LEVEL(int n)
        {
            this.n = n;
        }

        public long value()
        {
            return n;
        }
    }

    @Method(selector = "setLogLevel:visualLevel:")
    public native static void setLogLevel(ONE_S_LOG_LEVEL logLevel, ONE_S_LOG_LEVEL visualLevel);
}
Last edited by zgintasz on Thu May 05, 2016 5:31 pm, edited 1 time in total.
zgintasz
 
Posts: 52
Joined: Tue Jan 12, 2016 4:01 pm

Re: Convert Objective C header file for RoboVM/Java (no bro-

Postby katalay » Fri Oct 13, 2017 7:16 am

Hi,
Your example seems to be header file of OneSignal framework.
I want to use Onesignal push noticiation in my game. Is there a binded robovm/java of onesignal framework?
I tried but couldn't manage.
Thanks.
katalay
 
Posts: 3
Joined: Fri Oct 13, 2017 7:10 am

Re: Convert Objective C header file for RoboVM/Java (no bro-

Postby evilentity » Fri Oct 13, 2017 10:30 am

If you cant find it, there probably isnt one to find. Binding few methods isnt terribly difficult if you try hard enough.
Looking for a freelancer? PM me!
evilentity
 
Posts: 3896
Joined: Wed Aug 24, 2011 11:37 am


Return to Libgdx

Who is online

Users browsing this forum: evilentity, Exabot [Bot], Google [Bot] and 8 guests