参考
新版 robovm 友盟绑定参照这里 Libgdx IOS robovm 集成友盟
注意
导入系统库的 CoreTelePhony.framework
将 UMMobClick.framework 导入到 ios 下面的 libs 文件夹,没有则创建一个
然后如下图在 robovm.xml 中添加一下
图片看不到看原贴地址 http://blog.codegather.com/articles/2017/11/13/1510582666106.html
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 中即可
手机游戏源码素材网:http://www.codegather.com
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于