Open mwaked opened 4 years ago
Hello! Where do you initialize the sdk instance with UnifiedSDK.getInstance(ClientInfo)?
@timoshenkoav in the Application class
class MainApplication : Application() {
private var unifiedSDK: UnifiedSDK? = null
companion object {
const val CHANNEL_ID = "vpn"
var selectedCountry = UnifiedSDK.COUNTRY_OPTIMAL
private var mInstance: MainApplication? = null
@Synchronized
fun getInstance(): MainApplication {
if (mInstance == null) mInstance = MainApplication()
return mInstance!!
}
}
private val prefs: SharedPreferences
get() = getSharedPreferences(BuildConfig.SHARED_PREFS, Context.MODE_PRIVATE)
override fun onCreate() {
super.onCreate()
mInstance = this
initHydraSdk()
}
private fun initHydraSdk() {
createNotificationChannel()
val clientInfo = ClientInfo.newBuilder()
.baseUrl(prefs.getString(BuildConfig.STORED_HOST_URL_KEY, BuildConfig.BASE_HOST)!!)
.carrierId(prefs.getString(BuildConfig.STORED_CARRIER_ID_KEY, BuildConfig.BASE_CARRIER_ID)!!)
.build()
val transportConfigList: MutableList<TransportConfig> = ArrayList()
transportConfigList.add(HydraTransportConfig.create())
transportConfigList.add(OpenVpnTransportConfig.tcp())
transportConfigList.add(OpenVpnTransportConfig.udp())
UnifiedSDK.update(transportConfigList, CompletableCallback.EMPTY)
val config = UnifiedSDKConfig.newBuilder().idfaEnabled(false).build()
unifiedSDK = UnifiedSDK.getInstance(clientInfo, config)
val notificationConfig = NotificationConfig.newBuilder()
.title(resources.getString(R.string.app_name))
.channelId(CHANNEL_ID)
.build()
UnifiedSDK.update(notificationConfig)
UnifiedSDK.setLoggingLevel(Log.VERBOSE)
}
fun setNewHostAndCarrier(hostUrl: String?, carrierId: String?) {
if (TextUtils.isEmpty(hostUrl)) {
prefs.edit().remove(BuildConfig.STORED_HOST_URL_KEY).apply()
} else {
prefs.edit().putString(BuildConfig.STORED_HOST_URL_KEY, hostUrl).apply()
}
if (TextUtils.isEmpty(carrierId)) {
prefs.edit().remove(BuildConfig.STORED_CARRIER_ID_KEY).apply()
} else {
prefs.edit().putString(BuildConfig.STORED_CARRIER_ID_KEY, carrierId).apply()
}
initHydraSdk()
}
}
ok, everything seems fine. i will investigate the issue, for now you can try to switch and use UnifiedSDK instance you have in your application. instead of using UnifiedSDK.getInstance()
@timoshenkoav Ok, Thank you
@timoshenkoav can you please explain more about (UnifiedSDK instance you have in application. ?? )
This Exception happened with me with some devices and some devices not happen, just when i trying to open the app it throw this Exception, It's working fine with most devices but with some devices it throw this Exception!
It happens with this device![WhatsApp Image 2020-05-26 at 8 53 55 PM](https://user-images.githubusercontent.com/33099498/82934549-4d5ae480-9f94-11ea-8282-6eaed7dd50b0.jpeg)