增加firebase日志上传

This commit is contained in:
zhl 2023-03-21 19:24:54 +08:00
parent 7f7ece3659
commit c35e684acb
12 changed files with 877 additions and 655 deletions

View File

@ -34,6 +34,7 @@
#include <sys/sysctl.h>
#import <TikTokOpenSDK/TikTokOpenSDKApplicationDelegate.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
@import FirebaseCore;
// we assume that app delegate is never changed and we can cache it, instead of re-query UIApplication every time
UnityAppController* _UnityAppController = nil;
@ -398,6 +399,7 @@ extern "C" void UnityCleanupTrampoline()
[[TikTokOpenSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
[FIRApp configure];
return YES;
}

View File

@ -143,7 +143,7 @@ NS_CC_BEGIN
}
char *JcWallet::runJsMethod(std::shared_ptr<JSMethodParam> data) {
cocos2d::log("thread: %ld call method %s params: %d", uv_thread_self(), data->methodName.c_str(), data->args.size());
cocos2d::log("thread: %ld call method %s params: %lu", uv_thread_self(), data->methodName.c_str(), data->args.size());
se::Value value;
bool ok = cocos2d::runGlobalMethod(data->methodName.c_str(), data->args, &value);
static std::string result;
@ -219,7 +219,6 @@ NS_CC_BEGIN
});
return result == 0 ? 1 : 0;
}
}
int nativeCallBack(const char *funId, const char *methodName, const char *cparams) {

View File

@ -0,0 +1,15 @@
//
// UIViewController+Logger.h
// Unity-iPhone
//
// Created by Hl Zhang on 2023/3/21.
//
#pragma once
#import <UIKit/UIKit.h>
@interface UIViewController (Logger)
- (void)logEvent:(NSString *)content;
@end

View File

@ -0,0 +1,56 @@
//
// UIViewController+Logger.cpp
// Unity-iPhone
//
// Created by Hl Zhang on 2023/3/21.
//
#include <stdio.h>
#include <string>
#import "UIViewController+Logger.h"
#import <Foundation/Foundation.h>
#import "NSString+Customer.h"
@import FirebaseAnalytics;
@implementation UIViewController (Logger)
-(NSDictionary *)parseJSONString:(NSString *)jsonString{
NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSError *error = nil;
NSDictionary *result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
if (error != nil) {
NSLog(@"Error parsing JSON string: %@", error.localizedDescription);
return nil;
}
return result;
}
-(void)logEvent:(NSString *)content{
if ([NSString isStringEmpty:content]) {
NSLog(@"Content is empty");
return;
}
NSDictionary *jsonDict = [self parseJSONString:content];
if (jsonDict == nil) {
NSLog(@"Error parsing JSON string");
return;
}
NSString *name = jsonDict[@"name"];
if ([NSString isStringEmpty:name]) {
name = @"name";
}
[FIRAnalytics logEventWithName:@"custom_event" parameters:@{
@"content": content
}];
}
extern "C" void nativeLogEvent(const char *content) {
NSString *contentStr = [NSString stringWithCString:content encoding: NSUTF8StringEncoding];
dispatch_async(dispatch_get_main_queue(), ^{
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
[window.rootViewController logEvent: contentStr];
});
}
@end

View File

@ -0,0 +1,15 @@
//
// UIViewController+Share.h
// Unity-iPhone
//
// Created by Hl Zhang on 2023/3/20.
//
#pragma once
#import <UIKit/UIKit.h>
@interface UIViewController (Share)
- (void)shareToFacebook:(NSString *)title;
@end

View File

@ -0,0 +1,30 @@
//
// UIViewController+Share.cpp
// Unity-iPhone
//
// Created by Hl Zhang on 2023/3/20.
//
#include <string>
#import "UIViewController+Share.h"
#import <FBSDKShareKit/FBSDKShareKit.h>
@implementation UIViewController (Share)
-(void)shareToFacebook:(NSString *)title {
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = [NSURL URLWithString:@"https://www.example.com"];
content.quote = @"Check out this awesome website!";
FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] initWithViewController:self content:content delegate: nil];
[dialog show];
}
extern "C" void shareWithFacebook(const char *url) {
NSString *urlStr = [NSString stringWithCString:url encoding: NSUTF8StringEncoding];
NSLog(@"share with facebook: %@", urlStr);
dispatch_async(dispatch_get_main_queue(), ^{
UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
[window.rootViewController shareToFacebook:urlStr];
});
}
@end

34
GoogleService-Info.plist Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>977053300219-82os7bluuqfqc3fjv70q0f5n708osgke.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.977053300219-82os7bluuqfqc3fjv70q0f5n708osgke</string>
<key>API_KEY</key>
<string>AIzaSyCiLAay7JbfAhJ5lGyjqiDgv_0qz5tmwc8</string>
<key>GCM_SENDER_ID</key>
<string>977053300219</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.jc.tebg</string>
<key>PROJECT_ID</key>
<string>cebg-1a9ee</string>
<key>STORAGE_BUCKET</key>
<string>cebg-1a9ee.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:977053300219:ios:afea9deaf7a922cc41c75e</string>
</dict>
</plist>

View File

@ -5,4 +5,6 @@ target 'Unity-iPhone' do
pod 'GoogleSignIn', :path => '/Users/zhl/Downloads/sourcecode/google/GoogleSignIn-iOS/'
pod 'TikTokOpenSDK', '~> 5.0.14'
pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
pod 'FirebaseAnalytics'
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array/>
</plist>

View File

@ -30,8 +30,8 @@
filePath = "Classes/UnityAppController.mm"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "356"
endingLineNumber = "356"
startingLineNumber = "357"
endingLineNumber = "357"
landmarkName = "-application:didFinishLaunchingWithOptions:"
landmarkType = "7">
</BreakpointContent>
@ -148,5 +148,37 @@
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "C1B2AAC2-26E1-4FD0-A684-FE40E12627CD"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Classes_cocos/JcWallet.mm"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "182"
endingLineNumber = "182"
landmarkName = "JcWallet::jsToUnity(funId, msg)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "E0747763-2B1B-4962-9526-56C3D14B2FCC"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Classes_cocos/UIViewController+Share.mm"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "24"
endingLineNumber = "24"
landmarkName = "shareWithFacebook(url)"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>