Skip to content

Commit

Permalink
Merge pull request #209 from Countly/default_warn
Browse files Browse the repository at this point in the history
[Android] Add warnings to all SDK example apps that would check if propper credentials have been set or it still has the defaults.
  • Loading branch information
ArtursKadikis authored Jan 29, 2024
2 parents b4f6630 + 60d8a03 commit 5a87771
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
10 changes: 7 additions & 3 deletions app-kotlin/src/main/java/ly/count/android/demo/kotlin/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import android.app.Application
import android.util.Log
import ly.count.android.sdk.Countly
import ly.count.android.sdk.CountlyConfig
import ly.count.android.sdk.RemoteConfigCallback

//import ly.count.android.sdk.DeviceIdType

class App : Application() {
val COUNTLY_SERVER_URL = "YOUR_SERVER_URL"
val COUNTLY_SERVER_URL = "https://your.server.ly"
val COUNTLY_APP_KEY = "YOUR_APP_KEY"
override fun onCreate() {
super.onCreate()

if (COUNTLY_SERVER_URL == "https://your.server.ly" || COUNTLY_APP_KEY == "YOUR_APP_KEY") {
Log.e("CountlyDemo", "Please provide correct COUNTLY_SERVER_URL and COUNTLY_APP_KEY")
return
}

val countlyConfig = CountlyConfig(
this,
Expand All @@ -29,4 +33,4 @@ class App : Application() {

Countly.sharedInstance().init(countlyConfig)
}
}
}
13 changes: 10 additions & 3 deletions app-native/src/main/java/ly/count/android/demo/crash/App.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package ly.count.android.demo.crash;

import android.app.Application;
import android.util.Log;
import ly.count.android.sdk.Countly;
import ly.count.android.sdk.CountlyConfig;
import ly.count.android.sdknative.CountlyNative;

public class App extends Application {

final String COUNTLY_SERVER_URL = "https://try.count.ly";
final String COUNTLY_APP_KEY = "xxxxxxx";
final String COUNTLY_SERVER_URL = "https://your.server.ly";
final String COUNTLY_APP_KEY = "YOUR_APP_KEY";

@Override public void onCreate() {
super.onCreate();

if (COUNTLY_SERVER_URL.equals("https://your.server.ly") || COUNTLY_APP_KEY.equals("YOUR_APP_KEY")) {
Log.e("CountlyCrashDemo", "Please provide correct COUNTLY_SERVER_URL and COUNTLY_APP_KEY");
return;
}

Countly.applicationOnCreate();

CountlyConfig config = (new CountlyConfig(this, COUNTLY_APP_KEY, COUNTLY_SERVER_URL)).setDeviceId("4432")
Expand All @@ -23,4 +30,4 @@ public class App extends Application {

CountlyNative.initNative(getApplicationContext());
}
}
}
7 changes: 6 additions & 1 deletion app/src/main/java/ly/count/android/demo/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

public class App extends Application {
/** You should use try.count.ly instead of YOUR_SERVER for the line below if you are using Countly trial service */
final String COUNTLY_SERVER_URL = "YOUR_SERVER";
final String COUNTLY_SERVER_URL = "https://your.server.ly";
final String COUNTLY_APP_KEY = "YOUR_APP_KEY";
static long applicationStartTimestamp = System.currentTimeMillis();

Expand All @@ -44,6 +44,11 @@ public class App extends Application {
public void onCreate() {
super.onCreate();

if (COUNTLY_SERVER_URL.equals("https://your.server.ly") || COUNTLY_APP_KEY.equals("YOUR_APP_KEY")) {
Log.e("CountlyDemo", "Please provide correct COUNTLY_SERVER_URL and COUNTLY_APP_KEY");
return;
}

if (false) {
//setting up strict mode for additional validation
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
Expand Down

0 comments on commit 5a87771

Please sign in to comment.