增加tiktok登陆
This commit is contained in:
parent
9544638820
commit
6048aa3b5a
2
.idea/gradle.xml
generated
2
.idea/gradle.xml
generated
@ -13,7 +13,7 @@
|
|||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
<option value="$PROJECT_DIR$/../cocos_js/cocos/platform/android/libcocos2dx" />
|
<option value="$PROJECT_DIR$/../../cocos/cocos2d-x/cocos/platform/android/libcocos2dx" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
|
5
.idea/jarRepositories.xml
generated
5
.idea/jarRepositories.xml
generated
@ -21,5 +21,10 @@
|
|||||||
<option name="name" value="Google" />
|
<option name="name" value="Google" />
|
||||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://artifact.bytedance.com/repository/AwemeOpenSDK" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -15,7 +15,7 @@
|
|||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
@ -69,6 +69,10 @@
|
|||||||
<data android:scheme="com.googleusercontent.apps.53206975661-asnf3qe4bg29p8h981pgf099osvrjbme"/>
|
<data android:scheme="com.googleusercontent.apps.53206975661-asnf3qe4bg29p8h981pgf099osvrjbme"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".tiktokapi.TikTokEntryActivity"
|
||||||
|
android:exported="true">
|
||||||
|
</activity>
|
||||||
<service android:name ="com.youme.voiceengine.VoiceEngineService">
|
<service android:name ="com.youme.voiceengine.VoiceEngineService">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.youme.voiceengine.VoiceEngineService"/>
|
<action android:name="com.youme.voiceengine.VoiceEngineService"/>
|
||||||
@ -118,4 +122,8 @@
|
|||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||||
android:maxSdkVersion="29" />
|
android:maxSdkVersion="29" />
|
||||||
|
<queries>
|
||||||
|
<package android:name="com.zhiliaoapp.musically" />
|
||||||
|
<package android:name="com.ss.android.ugc.trill" />
|
||||||
|
</queries>
|
||||||
</manifest>
|
</manifest>
|
@ -139,4 +139,5 @@ dependencies {
|
|||||||
implementation 'com.android.volley:volley:1.2.1'
|
implementation 'com.android.volley:volley:1.2.1'
|
||||||
implementation 'org.greenrobot:eventbus:3.0.0'
|
implementation 'org.greenrobot:eventbus:3.0.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||||
|
implementation 'com.bytedance.ies.ugc.aweme:opensdk-oversea-external:0.2.1.0'
|
||||||
}
|
}
|
@ -18,6 +18,9 @@ import android.view.MotionEvent;
|
|||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.bytedance.sdk.open.tiktok.TikTokOpenApiFactory;
|
||||||
|
import com.bytedance.sdk.open.tiktok.api.TikTokOpenApi;
|
||||||
|
import com.bytedance.sdk.open.tiktok.authorize.model.Authorization;
|
||||||
import com.cege.games.release.activity.CustomCaptureActivity;
|
import com.cege.games.release.activity.CustomCaptureActivity;
|
||||||
import com.cege.games.release.dialog.QRCodeActivity;
|
import com.cege.games.release.dialog.QRCodeActivity;
|
||||||
import com.google.android.gms.auth.api.signin.GoogleSignIn;
|
import com.google.android.gms.auth.api.signin.GoogleSignIn;
|
||||||
@ -118,6 +121,10 @@ public class MainActivity extends Activity
|
|||||||
private CountDownLatch mAuthIntentLatch = new CountDownLatch(1);
|
private CountDownLatch mAuthIntentLatch = new CountDownLatch(1);
|
||||||
private static final String EXTRA_FAILED = "failed";
|
private static final String EXTRA_FAILED = "failed";
|
||||||
|
|
||||||
|
public String getFunId() {
|
||||||
|
return funId;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final BrowserMatcher mBrowserMatcher = AnyBrowserMatcher.INSTANCE;
|
private final BrowserMatcher mBrowserMatcher = AnyBrowserMatcher.INSTANCE;
|
||||||
|
|
||||||
@ -804,7 +811,21 @@ public class MainActivity extends Activity
|
|||||||
}
|
}
|
||||||
@MainThread
|
@MainThread
|
||||||
private void verifyGoogleIDToken(String idToken) {
|
private void verifyGoogleIDToken(String idToken) {
|
||||||
JcSDK.googleOauthCb(this.funId, null, idToken);
|
JcSDK.oauthCb(this.funId, null, idToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
// sign with tiktok
|
||||||
|
public void signWithTiktok(String funId) {
|
||||||
|
this.funId = funId;
|
||||||
|
Log.i(TAG, "login with tiktok: " + funId);
|
||||||
|
// STEP 1: Create an instance of TiktokOpenApi
|
||||||
|
TikTokOpenApi tiktokOpenApi= TikTokOpenApiFactory.create(this);
|
||||||
|
|
||||||
|
// STEP 2: Create an instance of Authorization.Request and set parameters
|
||||||
|
Authorization.Request request = new Authorization.Request();
|
||||||
|
request.scope = "user.info.basic,video.list";
|
||||||
|
request.state = funId;
|
||||||
|
tiktokOpenApi.authorize(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@ package com.cege.games.release;
|
|||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
|
import com.bytedance.sdk.open.tiktok.TikTokOpenApiFactory;
|
||||||
|
import com.bytedance.sdk.open.tiktok.TikTokOpenConfig;
|
||||||
|
|
||||||
public class MainApplication extends Application {
|
public class MainApplication extends Application {
|
||||||
public static MainApplication application;
|
public static MainApplication application;
|
||||||
public static SharedPreferences _pref;
|
public static SharedPreferences _pref;
|
||||||
@ -11,5 +14,7 @@ public class MainApplication extends Application {
|
|||||||
super.onCreate();
|
super.onCreate();
|
||||||
application = this;
|
application = this;
|
||||||
_pref = getSharedPreferences(Constants.PREF_NAME, 0);
|
_pref = getSharedPreferences(Constants.PREF_NAME, 0);
|
||||||
|
String tiktokClientKey = "awqbuzh2qymmq8hs";
|
||||||
|
TikTokOpenApiFactory.init(new TikTokOpenConfig(tiktokClientKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.cege.games.release.tiktokapi;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.bytedance.sdk.open.tiktok.TikTokOpenApiFactory;
|
||||||
|
import com.bytedance.sdk.open.tiktok.api.TikTokOpenApi;
|
||||||
|
import com.bytedance.sdk.open.tiktok.authorize.model.Authorization;
|
||||||
|
import com.bytedance.sdk.open.tiktok.common.handler.IApiEventHandler;
|
||||||
|
import com.bytedance.sdk.open.tiktok.common.model.BaseReq;
|
||||||
|
import com.bytedance.sdk.open.tiktok.common.model.BaseResp;
|
||||||
|
import com.jc.jcfw.JcSDK;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
public class TikTokEntryActivity extends Activity implements IApiEventHandler {
|
||||||
|
private static final String TAG = TikTokEntryActivity.class.getSimpleName();
|
||||||
|
TikTokOpenApi ttOpenApi;
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
ttOpenApi= TikTokOpenApiFactory.create(this);
|
||||||
|
ttOpenApi.handleIntent(getIntent(),this); // receive and parse callback
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onReq(BaseReq req) {
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onResp(BaseResp resp) {
|
||||||
|
if (resp instanceof Authorization.Response) {
|
||||||
|
Authorization.Response response = (Authorization.Response) resp;
|
||||||
|
// Log.i(TAG, "errorCode: " + response.errorCode);
|
||||||
|
// Log.i(TAG, "errorMsg: " + response.errorMsg);
|
||||||
|
// Log.i(TAG, "authCode: " + response.authCode);
|
||||||
|
// Log.i(TAG, "state: " + response.state);
|
||||||
|
// Log.i(TAG, "grantedPermissions: " + response.grantedPermissions);
|
||||||
|
if (response.errorCode == 0) {
|
||||||
|
JcSDK.oauthCb(response.state, null, response.authCode);
|
||||||
|
} else {
|
||||||
|
JcSDK.oauthCb(response.state, response.errorMsg, null);
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onErrorIntent(@Nullable Intent intent) {
|
||||||
|
JcSDK.oauthCb(null, "error intent", null);
|
||||||
|
}
|
||||||
|
}
|
@ -76,6 +76,10 @@ public class JcSDK {
|
|||||||
MainActivity.app.loadRestoreKey(funid, oid);
|
MainActivity.app.loadRestoreKey(funid, oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void signWithTiktok(String funid) {
|
||||||
|
MainActivity.app.signWithTiktok(funid);
|
||||||
|
}
|
||||||
|
|
||||||
public static void signWithGoogle(String funid) {
|
public static void signWithGoogle(String funid) {
|
||||||
MainActivity.app.signWithGoogle(funid);
|
MainActivity.app.signWithGoogle(funid);
|
||||||
}
|
}
|
||||||
@ -84,7 +88,7 @@ public class JcSDK {
|
|||||||
MainActivity.app.signOutGoogle(funid);
|
MainActivity.app.signOutGoogle(funid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void googleOauthCb(String funId, String error, String idToken) {
|
public static void oauthCb(String funId, String error, String idToken) {
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
try {
|
try {
|
||||||
if (error != "" && null != error) {
|
if (error != "" && null != error) {
|
||||||
@ -97,7 +101,10 @@ public class JcSDK {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
if (null == funId || "".equals(funId)) {
|
||||||
|
funId = MainActivity.app.getFunId();
|
||||||
|
}
|
||||||
|
Log.i("TAG" ,result.toString());
|
||||||
String methodName = "jniCallback";
|
String methodName = "jniCallback";
|
||||||
JcSDK.runJS(funId, methodName, result.toString());
|
JcSDK.runJS(funId, methodName, result.toString());
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ buildscript {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven { url "https://artifact.bytedance.com/repository/AwemeOpenSDK" }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "com.android.tools.build:gradle:4.1.1"
|
classpath "com.android.tools.build:gradle:4.1.1"
|
||||||
@ -17,6 +18,7 @@ allprojects {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven { url "https://artifact.bytedance.com/repository/AwemeOpenSDK" }
|
||||||
flatDir {
|
flatDir {
|
||||||
dirs 'libs'
|
dirs 'libs'
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
function jniCallback(...args) {
|
function jniCallback(...args) {
|
||||||
console.log(`jniCallback: ${args[0]}`)
|
console.log(`jniCallback: ${args[0]} | ${args[1]}`);
|
||||||
jc.wallet.nativeSvr.handleNativeCallback(...args);
|
jc.wallet.nativeSvr.handleNativeCallback(...args);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user