華爲Game服務-遊戲啓動過程有兩個關鍵開發步驟:一是在Application的onCreate方法中添加代碼,用於註冊Activity的回調監聽;二是調用JosAppsClient.init方法進行初始化。java
Cocos SDKHub服務會自動完成開發步驟一;對於開發步驟二,也提供了初始化方法給用戶調用。api
SDKHub提供的初始化調用方法示例以下:session
sdkhub.getUserPlugin().callFuncWithParam("init");
須要注意的是: 初始化方法須要在遊戲啓動時完成,且若是應用提供了用戶隱私協議,還須要判斷在用戶贊成協議後調用,拒絕協議後不調用。該方法用於展現遊戲公告等。app
調用初始化信息後會在日誌中打印以下信息:post
I/HMSSDK_HMSBIInitializer: Builder->biInitFlag :true I/HMSSDK_JosAppsClientImpl: request Jos Notice. I/HMSSDK_HmsClient: post msg api_name:core.getNoticeIntent, app_id:103468471|, pkg_name:com.cocos2d.checkUpdate, sdk_version:50000302, session_id:*, transaction_id:103468471Intent20201214203645835197672, kitSdkVersion:50001302, apiLevel:1 I/HMSSDK_BaseAdapter: in baseRequest + uri is :core.getNoticeIntent, transactionId is : 103468471Intent20201214203645835197672 I/HMSSDK_PendingResultImpl: init uri:core.getNoticeIntent I/HMSSDK_PendingResultImpl: setResultCallback I/HMSSDK_PendingResultImpl: setResult:0 I/HMSSDK_BaseAdapter: baseCallBack.onComplete I/HMSSDK_HmsClient: receive msg status_code:0, error_code8002, api_name:core.getNoticeIntent, app_id:103468471|, pkg_name:com.cocos2d.checkUpdate, session_id:*, transaction_id:103468471Intent20201214203645835197672, resolution:null W/HMSSDK_NoticeTaskApiCall: Jos Notice onResult failed:8002,ErrReason:
注:init方法不返回執行結果,應用無需關注執行結果。ui
原文連接:https://developer.huawei.com/consumer/cn/forum/topic/0202441261864100427?fid=0101271690375130218日誌
原做者:Mayismcode