From 34a150d81c36b1d08273099411fe83ac32b70421 Mon Sep 17 00:00:00 2001 From: mikemilla Date: Fri, 28 Oct 2022 12:39:54 -0400 Subject: [PATCH] Removed Google Services for Jitpack --- app/build.gradle | 1 - app/src/google-services.json | 2 - .../java/com/courier/example/MainActivity.kt | 44 ++++++++++++++++--- build.gradle | 3 -- 4 files changed, 38 insertions(+), 12 deletions(-) delete mode 100644 app/src/google-services.json diff --git a/app/build.gradle b/app/build.gradle index 58a447f..11e0de9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,6 @@ plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' - id 'com.google.gms.google-services' // Firebase requirement } android { diff --git a/app/src/google-services.json b/app/src/google-services.json deleted file mode 100644 index 7a73a41..0000000 --- a/app/src/google-services.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/app/src/main/java/com/courier/example/MainActivity.kt b/app/src/main/java/com/courier/example/MainActivity.kt index 0084977..29c4c9a 100644 --- a/app/src/main/java/com/courier/example/MainActivity.kt +++ b/app/src/main/java/com/courier/example/MainActivity.kt @@ -47,12 +47,45 @@ class MainActivity : CourierActivity(), CourierPushNotificationCallbacks { private suspend fun setup() { - // Init Courier - Courier.initialize(context = this) + try { + + val hasNotificationPermissions = requestNotificationPermission() + Toast.makeText(this@MainActivity, "Notification permissions are granted: $hasNotificationPermissions", Toast.LENGTH_LONG).show() + + prefs = showSDKConfig( + activity = this@MainActivity, + title = "Configure SDK", + items = listOf( + DialogItem("FIREBASE_API_KEY", "Firebase API Key"), + DialogItem("FIREBASE_APP_ID", "Firebase App ID"), + DialogItem("FIREBASE_PROJECT_ID", "Firebase Project ID"), + DialogItem("FIREBASE_GCM_SENDER_ID", "Firebase GCM Sender ID"), + DialogItem("COURIER_AUTH_KEY", "Courier Auth Key"), + ) + ) + + // Start firebase + // This must be set before you can sync FCM tokens in Courier + val options = FirebaseOptions.Builder().apply { + setApiKey(prefs.getString("FIREBASE_API_KEY", "") ?: "") + setApplicationId(prefs.getString("FIREBASE_APP_ID", "") ?: "") + setProjectId(prefs.getString("FIREBASE_PROJECT_ID", "") ?: "") + setGcmSenderId(prefs.getString("FIREBASE_GCM_SENDER_ID", "") ?: "") + }.build() + + FirebaseApp.initializeApp(this@MainActivity, options) + + // Init Courier + Courier.initialize(context = this) + + Toast.makeText(this, "SDK Initialized", Toast.LENGTH_LONG).show() - // Request push notification permissions - val hasNotificationPermissions = requestNotificationPermission() - Toast.makeText(this@MainActivity, "Notification permissions are granted: $hasNotificationPermissions", Toast.LENGTH_LONG).show() + } catch (e: Exception) { + + Toast.makeText(this@MainActivity, e.toString(), Toast.LENGTH_LONG).show() + setup() + + } } @@ -127,7 +160,6 @@ class MainActivity : CourierActivity(), CourierPushNotificationCallbacks { activity = this@MainActivity, title = "Sign into Courier", items = listOf( - DialogItem("COURIER_AUTH_KEY", "Courier Auth Key"), DialogItem("COURIER_ACCESS_TOKEN", "Courier Access Token"), DialogItem("COURIER_USER_ID", "Courier User ID"), ) diff --git a/build.gradle b/build.gradle index 8ebd9c8..2527e44 100644 --- a/build.gradle +++ b/build.gradle @@ -5,9 +5,6 @@ buildscript { google() mavenCentral() } - dependencies { - classpath 'com.google.gms:google-services:4.3.13' // Firebase requirement - } } plugins {