libgdx robovm Umeng 绑定

参考

新版 robovm 友盟绑定参照这里Libgdx IOS robovm 集成友盟

注意

导入系统库的 CoreTelePhony.framework
将 UMMobClick.framework 导入到 ios 下面的 libs 文件夹,没有则创建一个
然后如下图在 robovm.xml 中添加一下
图片看不到看原贴地址http://blog.codegather.com/articles/2017/11/13/1510582666106.html
d549041054ec4472b34798e80051b489-0C82EAD9CDC74102BD10154641B39145.png
MobClick.java

package cn.cbxjj.memorymaster;

import org.robovm.apple.foundation.NSObject;
import org.robovm.apple.uikit.UIAlertView;
import org.robovm.apple.uikit.UIAlertViewDelegate;
import org.robovm.objc.annotation.Method;
import org.robovm.objc.annotation.NativeClass;
import org.robovm.rt.bro.annotation.Library;
import org.robovm.rt.bro.annotation.MachineSizedSInt;

/**
 * Created by xxx on 2017/11/1. */@Library(Library.INTERNAL)
@NativeClass
public class MobClick extends NSObject implements UIAlertViewDelegate {

    @Override
 @Method(selector = "alertView:clickedButtonAtIndex:")
    public void clicked(UIAlertView alertView, @MachineSizedSInt long buttonIndex) {

    }

    @Override
 @Method(selector = "alertViewCancel:")
    public void cancel(UIAlertView alertView) {

    }

    @Override
 @Method(selector = "willPresentAlertView:")
    public void willPresent(UIAlertView alertView) {

    }

    @Override
 @Method(selector = "didPresentAlertView:")
    public void didPresent(UIAlertView alertView) {

    }

    @Override
 @Method(selector = "alertView:willDismissWithButtonIndex:")
    public void willDismiss(UIAlertView alertView, @MachineSizedSInt long buttonIndex) {

    }

    @Override
 @Method(selector = "alertView:didDismissWithButtonIndex:")
    public void didDismiss(UIAlertView alertView, @MachineSizedSInt long buttonIndex) {

    }

    @Override
 @Method(selector = "alertViewShouldEnableFirstOtherButton:")
    public boolean shouldEnableFirstOtherButton(UIAlertView alertView) {
        return false;
    }

    @Method(selector = "startWithConfigure:")
    public native static void startWithConfigure(UMAnalyticsConfig config);

    @Method(selector = "setLogEnabled:")
    public native static void setLogEnabled(boolean flag);
}

ReportPolicy.java

package cn.cbxjj.memorymaster;

import org.robovm.rt.bro.ValuedEnum;

/**
 * Created by xxx on 2017/11/2. */
public enum ReportPolicy implements ValuedEnum {
    REALTIME(0),
    BATCH(1),
    SEND_INTERVAL(6),
    SMART_POLICY(8);

    private final long n;

    private ReportPolicy(long n) {
        this.n = n;
    }

    @Override
  public long value() {
        return n;
    }
}

UMAnalyticsConfig.java

package cn.cbxjj.memorymaster;

/**
 * Created by xxx on 2017/11/1. */
import org.robovm.apple.foundation.NSObject;
import org.robovm.objc.annotation.Method;
import org.robovm.objc.annotation.NativeClass;
import org.robovm.objc.annotation.Property;
import org.robovm.rt.bro.annotation.Library;

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

    @Property
  public native void setAppKey(String appKey);

    @Property
  public native String getAppKey();

    @Property
  public native String getSecret();

    @Property
  public native void setSecret(String secret);

    @Property
  public native String getChannelId();

    @Property
  public native void setChannelId(String channelId);

    @Property
  public native boolean getBCrashReportEnabled();

    @Property
  public native void setBCrashReportEnabled(boolean bCrashReportEnabled);

    @Property
  public native ReportPolicy getEPolicy();

    @Property
  public native void setEPolicy(ReportPolicy ePolicy);

    @Method(selector = "sharedInstance")
    public native static UMAnalyticsConfig sharedInstance();
}

然后在 IOSLauncher.java 中即可
9aa3fb95e55d4c5692886cfb57e6de02-9C51D3CFBFDD435E9C2BF74EE880A922.png



手机游戏源码素材网:http://www.codegather.com