android BranchSDK:用户会话尚未初始化

3mpgtkmj  于 2023-04-10  发布在  Android
关注(0)|答案(4)|浏览(195)

我的BranchSDK有问题,在初始化过程中我收到错误:
12-28 13:50:22.203 D/FirebasePerformance: Logging NetworkRequestMetric - [https://api2.branch.io/v1/install](https://api2.branch.io/v1/install) 0b 1136ms, 12-28 13:50:22.204 I/FirebasePerformance: Did not receive a HTTP Response Code 12-28 13:50:22.204 W/FirebasePerformance: Unable to process the PerfMetric due to missing or invalid values. See earlier log statements for additional information on the specific missing/invalid values. 12-28 13:50:22.208 E/BranchNetworkClient: Error in doRestfulGet( [https://api2.branch.io/v1/install](https://api2.branch.io/v1/install) ) javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x63395a88: Failure in SSL library, usually a protocol error error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:744 0x5d9ce808:0x00000000) at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:449) at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:318) at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:282) at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:167) at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257) at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135) at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200) at okhttp3.RealCall.execute(RealCall.java:77) at com.google.firebase.perf.network.FirebasePerfOkHttpClient.execute(Unknown Source) at com.riversoft.eventssion.network.BranchNetworkClient.doRestfulPost(BranchNetworkClient.java:59) at io.branch.referral.network.BranchRemoteInterface.make_restful_post(BranchRemoteInterface.java:136) at io.branch.referral.Branch$BranchPostTask.doInBackground(Branch.java:2860) at io.branch.referral.Branch$BranchPostTask.doInBackground(Branch.java:2835) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x63395a88: Failure in SSL library, usually a protocol error error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:744 0x5d9ce808:0x00000000) at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:406) ... 29 more
我试过:https://github.com/BranchMetrics/android-branch-deep-linking/issues/552和:

ConnectionSpec spec = new 
ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)  
    .tlsVersions(TlsVersion.TLS_1_2)
    .cipherSuites(
          CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
          CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
          CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256)
    .build();

OkHttpClient client = new OkHttpClient.Builder() 
    .connectionSpecs(Collections.singletonList(spec))
    .build();

P.S.这是API19上的问题,但API 28,27,25,23都工作得很好。

jyztefdp

jyztefdp1#

请确认您正在使用的SDK版本?因为我们最新的SDK版本有一些TLS相关的更改。
请参阅:https://github.com/BranchMetrics/android-branch-deep-linking/releases
其中3.0.0版有一些与TLS相关的更改。如果问题仍然存在,请更新分支SDK并写信至integrations@branch.io。
谢谢。

kq4fsx7k

kq4fsx7k2#

对于3.0.3及以下版本,帮助我在初始化BranchSDK时只添加了一个字符串:ProviderInstaller.installIfNeeded(context);

mnowg1ta

mnowg1ta3#

在basapplicationoncreate方法上添加此行

Branch.getAutoInstance(this);
368yc8dk

368yc8dk4#

对于React Native Expo IOS(react-native-branch@5.4.0@config-plugins/react-native-branch@5.0.0expo@48.0.10),只需确保实现

#import "AppDelegate.h"
#import <RNBranch/RNBranch.h>
  
@implementation AppDelegate
  
// Initialize the Branch Session at the top of existing application:didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Uncomment this line to use the test key instead of the live one.
    // [RNBranch useTestInstance];
    [RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES];
    NSURL *jsCodeLocation;
    //...
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    [RNBranch application:application openURL:url options:options];
    return YES;
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
   [RNBranch continueUserActivity:userActivity];
   return YES;
}

在官方文档中,它使用

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    [RNBranch application:app openURL:url options:options];
    return YES;
}

但是它在我的环境中抛出了use of undeclared identifier 'app'错误。我不得不将app改为application来强制执行这项工作。

相关问题