Skip to content

Commit 9331ce5

Browse files
committed
Release 1.6
1 parent 5cb3e21 commit 9331ce5

File tree

7 files changed

+58
-5
lines changed

7 files changed

+58
-5
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ android {
1111
applicationId = "io.branch.branchlinksimulator"
1212
minSdk = 26
1313
targetSdk = 34
14-
versionCode = 12
15-
versionName = "1.2"
14+
versionCode = 16
15+
versionName = "1.6"
1616

1717
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1818
vectorDrawables {

app/release/app-release.aab

204 Bytes
Binary file not shown.

app/release/app-release.apk

176 Bytes
Binary file not shown.

app/release/output-metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"type": "SINGLE",
1212
"filters": [],
1313
"attributes": [],
14-
"versionCode": 1,
15-
"versionName": "1.0",
14+
"versionCode": 14,
15+
"versionName": "1.4",
1616
"outputFile": "app-release.apk"
1717
}
1818
],

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<action android:name="android.intent.action.VIEW" />
3939
<category android:name="android.intent.category.DEFAULT" />
4040
<category android:name="android.intent.category.BROWSABLE" />
41+
<data android:scheme="https" android:host="allergics.org" />
4142
<data android:scheme="https" android:host="branchlinksimulator.app.link" />
4243
<data android:scheme="https" android:host="branchlinksimulator-alternate.app.link" />
4344
</intent-filter>
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
package io.branch.branchlinksimulator
22

33
import android.app.Application
4+
import android.content.Context
45
import io.branch.referral.Branch
6+
import java.util.UUID
57

68
class BranchLinkSimulatorApplication: Application() {
79
override fun onCreate() {
810
super.onCreate()
911

1012
// Branch logging for debugging
1113
Branch.enableLogging()
12-
//Branch.getInstance().setIdentity("test_user")
14+
Branch.setAPIUrl("https://protected-api-test.branch.io/")
1315

1416
// Branch object initialization
1517
Branch.getAutoInstance(this)
18+
19+
// Retrieve or create the bls_session_id
20+
val sharedPreferences = getSharedPreferences("branch_session_prefs", Context.MODE_PRIVATE)
21+
val blsSessionId = sharedPreferences.getString("bls_session_id", null) ?: run {
22+
val newId = UUID.randomUUID().toString()
23+
sharedPreferences.edit().putString("bls_session_id", newId).apply()
24+
newId
25+
}
26+
27+
// Set the bls_session_id in Branch request metadata
28+
Branch.getInstance().setRequestMetadata("bls_session_id", blsSessionId)
29+
1630
}
1731
}

app/src/main/java/io/branch/branchlinksimulator/MainActivity.kt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import androidx.compose.material3.Icon
6363
import androidx.compose.ui.graphics.ColorFilter
6464
import androidx.compose.ui.unit.sp
6565
import io.branch.referral.PrefHelper
66+
import java.util.UUID
6667

6768
var customerEventAlias = "alias"
6869

@@ -151,10 +152,17 @@ fun MainContent(navController: NavController) {
151152
val context = LocalContext.current
152153
var showAPIDialog by remember { mutableStateOf(false) }
153154
var showAliasDialog by remember { mutableStateOf(false) }
155+
var showSessionIdDialog by remember { mutableStateOf(false) }
154156

155157
var textFieldValue by remember { mutableStateOf(PrefHelper.getInstance(context).apiBaseUrl) }
156158
var aliasValue by remember { mutableStateOf("") }
157159

160+
val sharedPreferences = context.getSharedPreferences("branch_session_prefs", Context.MODE_PRIVATE)
161+
val blsSessionId = sharedPreferences.getString("bls_session_id", null) ?: UUID.randomUUID().toString().also {
162+
sharedPreferences.edit().putString("bls_session_id", it).apply()
163+
}
164+
var sessionIdValue by remember { mutableStateOf(blsSessionId) }
165+
158166
Column(modifier = Modifier.padding(16.dp)) {
159167
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
160168
Image(
@@ -184,6 +192,10 @@ fun MainContent(navController: NavController) {
184192
showAliasDialog = true
185193
}
186194

195+
RoundedButton(title = "Change App's Session ID", icon = R.drawable.branch_badge_all_white) {
196+
showSessionIdDialog = true
197+
}
198+
187199
if (showAPIDialog) {
188200
AlertDialog(
189201
onDismissRequest = { showAPIDialog = false },
@@ -229,6 +241,32 @@ fun MainContent(navController: NavController) {
229241
}
230242
)
231243
}
244+
245+
if (showSessionIdDialog) {
246+
247+
AlertDialog(
248+
onDismissRequest = { showSessionIdDialog = false },
249+
title = { Text("Enter A Session ID") },
250+
text = {
251+
TextField(
252+
value = sessionIdValue,
253+
onValueChange = { sessionIdValue = it },
254+
label = { Text("Ex. testingSession02") },
255+
)
256+
},
257+
confirmButton = {
258+
TextButton(onClick = {
259+
Branch.getInstance().setRequestMetadata("bls_session_id", sessionIdValue)
260+
sharedPreferences.edit().putString("bls_session_id", sessionIdValue).apply()
261+
262+
Toast.makeText(context, "Set App's Session ID to $sessionIdValue", Toast.LENGTH_SHORT).show()
263+
showSessionIdDialog = false
264+
}) {
265+
Text("Save")
266+
}
267+
}
268+
)
269+
}
232270
}
233271
}
234272

0 commit comments

Comments
 (0)