52 lines
1.7 KiB
Plaintext
52 lines
1.7 KiB
Plaintext
#import "iOSBridgePlugin.h"
|
|
#import <UIKit/UIKit.h>
|
|
#import <EventMark.h>
|
|
|
|
@implementation iOSBridgePlugin
|
|
|
|
+ (void)openURL:(NSString *)url1
|
|
{
|
|
// 使用UIApplication的openURL方法打开外部浏览器
|
|
NSURL *url = [NSURL URLWithString:url1];
|
|
if (url && [[UIApplication sharedApplication] canOpenURL:url]) {
|
|
// 使用iOS 10及以上版本推荐的方法
|
|
[[UIApplication sharedApplication] openURL:url
|
|
options:@{}
|
|
completionHandler:nil];
|
|
} else {
|
|
// URL无效或无法打开
|
|
NSLog(@"Invalid URL or cannot open URL: %@", url1);
|
|
}
|
|
}
|
|
|
|
// 为了让Unity能够找到这个方法,我们需要提供一个C风格的函数入口点
|
|
extern "C"
|
|
{
|
|
void _openURL(const char* url)
|
|
{
|
|
// 将C风格的字符串转换为NSString,并调用openURL方法
|
|
[iOSBridgePlugin openURL:[NSString stringWithUTF8String:url]];
|
|
}
|
|
|
|
void _dataEyeEvent(const char* dictionaryJson, const char* eventName)
|
|
{
|
|
// NSLog(@"barry _dataEyeEvent Json== %s", dictionaryJson);
|
|
// NSLog(@"barry _dataEyeEvent eventName== %s", eventName);
|
|
// 将C风格的字符串转换为NSString
|
|
NSString *jsonString = [NSString stringWithUTF8String:dictionaryJson];
|
|
NSString *eventNameString = [NSString stringWithUTF8String:eventName];
|
|
|
|
// NSLog(@"barry _dataEyeEvent Json== %@", jsonString);
|
|
// NSLog(@"barry _dataEyeEvent eventName== %@", eventNameString);
|
|
|
|
// 调用trackProduct方法并传递两个参数
|
|
[[EventMark sharedEventMark] trackProduct:eventNameString dictionaryJson:jsonString];
|
|
}
|
|
}
|
|
- (void)initDataEyeSDK
|
|
{
|
|
|
|
}
|
|
|
|
@end
|