Skip to content

Commit

Permalink
version 1.3.7 - async get sid
Browse files Browse the repository at this point in the history
  • Loading branch information
PNixx committed Jun 23, 2021
1 parent 36b8e49 commit 3cf0a16
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ if( getIntent().getExtras() != null ) {
```
Params params = new Params();
params.put(Params.Parameter.EXTENDED, true);
recommender_params.put(Params.Parameter.ITEM, "37");
params.put(Params.Parameter.ITEM, "37");
REES46.recommend("RECOMMENDER_CODE", params, new Api.OnApiCallbackListener() {
@Override
public void onSuccess(JSONObject response) {
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ buildscript {

repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.3.5'
}
}
Expand All @@ -22,7 +22,7 @@ plugins {
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
3 changes: 2 additions & 1 deletion personalizatio-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'signing'

version='1.3.6'
version='1.3.7'

android {
compileSdkVersion 29
Expand All @@ -14,6 +14,7 @@ android {
targetSdkVersion 29
versionCode 1
versionName version
buildConfigField "String", "VERSION_NAME", "\"" + version + "\""
}

buildTypes {
Expand Down
24 changes: 16 additions & 8 deletions personalizatio-sdk/src/main/java/com/personalizatio/SDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.provider.Settings;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.util.Consumer;

import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.installations.FirebaseInstallations;
import com.google.firebase.messaging.RemoteMessage;
import com.personalizatio.Params.InternalParameter;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -273,10 +273,14 @@ public static String getDid() {

/**
* Возвращает идентификатор сессии
* @return String
*/
public static String getSid() {
return instance.seance;
public static void getSid(Consumer<String> listener) {
Thread thread = new Thread(() -> listener.accept(instance.seance));
if( instance.initialized ) {
thread.start();
} else {
instance.queue.add(thread);
}
}

//----------Private--------------->
Expand Down Expand Up @@ -439,6 +443,10 @@ private void getToken() {
SDK.error("getInstanceId failed", task.getException());
return;
}
if( task.getResult() == null ) {
SDK.error("Firebase result is null");
return;
}

// Get new Instance ID token
final String token = task.getResult().getToken();
Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ configurations {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

// rees46DebugImplementation project(path: ':personalizatio-sdk', configuration: 'rees46Debug')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import androidx.core.app.NotificationCompat;
import android.util.Log;

import com.personalizatio.Api;
import com.personalizatio.OnMessageListener;
import com.personalizatio.SDK;
import com.rees46.sdk.REES46;
Expand All @@ -37,6 +38,7 @@ public void onCreate() {

//Demo shop
initialize();
T.getSid(sid -> Log.d("APP", "sid: " + sid));
T.setOnMessageListener(new OnMessageListener() {
@SuppressLint("StaticFieldLeak")
@Override
Expand Down

0 comments on commit 3cf0a16

Please sign in to comment.