-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #509 from mr-kew/messaging-api-frame
Firebase messaging frame
- Loading branch information
Showing
17 changed files
with
357 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree | ||
|
||
/* | ||
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
version = project.property("firebase-messaging.version") as String | ||
|
||
plugins { | ||
id("com.android.library") | ||
kotlin("multiplatform") | ||
kotlin("native.cocoapods") | ||
} | ||
|
||
android { | ||
val minSdkVersion: Int by project | ||
val compileSdkVersion: Int by project | ||
|
||
compileSdk = compileSdkVersion | ||
namespace = "dev.gitlive.firebase.messaging" | ||
|
||
defaultConfig { | ||
minSdk = minSdkVersion | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
testOptions { | ||
unitTests.apply { | ||
isIncludeAndroidResources = true | ||
} | ||
} | ||
packaging { | ||
resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") | ||
resources.pickFirsts.add("META-INF/AL2.0") | ||
resources.pickFirsts.add("META-INF/LGPL2.1") | ||
} | ||
lint { | ||
abortOnError = false | ||
} | ||
} | ||
|
||
val supportIosTarget = project.property("skipIosTarget") != "true" | ||
|
||
kotlin { | ||
|
||
targets.configureEach { | ||
compilations.configureEach { | ||
kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" | ||
} | ||
} | ||
|
||
@Suppress("OPT_IN_USAGE") | ||
androidTarget { | ||
instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) | ||
unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) | ||
publishAllLibraryVariants() | ||
compilations.configureEach { | ||
kotlinOptions { | ||
jvmTarget = "11" | ||
} | ||
} | ||
} | ||
|
||
if (supportIosTarget) { | ||
iosArm64() | ||
iosX64() | ||
iosSimulatorArm64() | ||
cocoapods { | ||
ios.deploymentTarget = "12.0" | ||
framework { | ||
baseName = "FirebaseMessaging" | ||
} | ||
noPodspec() | ||
pod("FirebaseMessaging") { | ||
version = "10.25.0" | ||
} | ||
} | ||
} | ||
|
||
js(IR) { | ||
useCommonJs() | ||
nodejs { | ||
testTask( | ||
Action { | ||
useKarma { | ||
useChromeHeadless() | ||
} | ||
} | ||
) | ||
} | ||
browser { | ||
testTask( | ||
Action { | ||
useKarma { | ||
useChromeHeadless() | ||
} | ||
} | ||
) | ||
} | ||
} | ||
|
||
jvm { | ||
compilations.getByName("main") { | ||
kotlinOptions { | ||
jvmTarget = "17" | ||
} | ||
} | ||
compilations.getByName("test") { | ||
kotlinOptions { | ||
jvmTarget = "17" | ||
} | ||
} | ||
} | ||
|
||
sourceSets { | ||
all { | ||
languageSettings.apply { | ||
val apiVersion: String by project | ||
val languageVersion: String by project | ||
this.apiVersion = apiVersion | ||
this.languageVersion = languageVersion | ||
progressiveMode = true | ||
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") | ||
if (name.lowercase().contains("ios")) { | ||
optIn("kotlinx.cinterop.ExperimentalForeignApi") | ||
optIn("kotlinx.cinterop.BetaInteropApi") | ||
} | ||
} | ||
} | ||
|
||
getByName("commonMain") { | ||
dependencies { | ||
api(project(":firebase-app")) | ||
implementation(project(":firebase-common")) | ||
} | ||
} | ||
|
||
getByName("commonTest") { | ||
dependencies { | ||
implementation(project(":test-utils")) | ||
} | ||
} | ||
|
||
getByName("androidMain") { | ||
dependencies { | ||
api("com.google.firebase:firebase-messaging") | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (project.property("firebase-messaging.skipIosTests") == "true") { | ||
tasks.forEach { | ||
if (it.name.contains("ios", true) && it.name.contains("test", true)) { it.enabled = false } | ||
} | ||
} | ||
|
||
if (project.property("firebase-messaging.skipJsTests") == "true") { | ||
tasks.forEach { | ||
if (it.name.contains("js", true) && it.name.contains("test", true)) { it.enabled = false } | ||
} | ||
} | ||
|
||
signing { | ||
val signingKey: String? by project | ||
val signingPassword: String? by project | ||
useInMemoryPgpKeys(signingKey, signingPassword) | ||
sign(publishing.publications) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Pod::Spec.new do |spec| | ||
spec.name = 'firebase_messaging' | ||
spec.version = '1.8.1' | ||
spec.homepage = '' | ||
spec.source = { :http=> ''} | ||
spec.authors = '' | ||
spec.license = '' | ||
spec.summary = '' | ||
spec.vendored_frameworks = 'build/cocoapods/framework/firebase_messaging.framework' | ||
spec.libraries = 'c++' | ||
|
||
|
||
|
||
spec.pod_target_xcconfig = { | ||
'KOTLIN_PROJECT_PATH' => ':firebase-messaging', | ||
'PRODUCT_MODULE_NAME' => 'firebase_messaging', | ||
} | ||
|
||
spec.script_phases = [ | ||
{ | ||
:name => 'Build firebase_messaging', | ||
:execution_position => :before_compile, | ||
:shell_path => '/bin/sh', | ||
:script => <<-SCRIPT | ||
if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then | ||
echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" | ||
exit 0 | ||
fi | ||
set -ev | ||
REPO_ROOT="$PODS_TARGET_SRCROOT" | ||
"$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ | ||
-Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ | ||
-Pkotlin.native.cocoapods.archs="$ARCHS" \ | ||
-Pkotlin.native.cocoapods.configuration="$CONFIGURATION" | ||
SCRIPT | ||
} | ||
] | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "@gitlive/firebase-messaging", | ||
"version": "1.12.0", | ||
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", | ||
"main": "firebase-messaging.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/GitLiveApp/firebase-kotlin-sdk.git" | ||
}, | ||
"keywords": [ | ||
"kotlin", | ||
"multiplatform", | ||
"kotlin-js", | ||
"firebase" | ||
], | ||
"author": "dev.gitlive", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/GitLiveApp/firebase-kotlin-sdk/issues" | ||
}, | ||
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", | ||
"dependencies": { | ||
"@gitlive/firebase-app": "1.12.0", | ||
"firebase": "9.19.1", | ||
"kotlin": "1.8.20", | ||
"kotlinx-coroutines-core": "1.6.4" | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...-messaging/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.gitlive.firebase.messaging | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import dev.gitlive.firebase.Firebase | ||
import dev.gitlive.firebase.FirebaseOptions | ||
import dev.gitlive.firebase.apps | ||
import dev.gitlive.firebase.initialize | ||
import kotlin.test.BeforeTest | ||
|
||
class AndroidInstrumentedFirebaseMessagingTest : FirebaseMessagingTest() { | ||
|
||
private val context = InstrumentationRegistry.getInstrumentation().context | ||
|
||
@BeforeTest | ||
fun initializeFirebase() { | ||
Firebase.apps(context).firstOrNull() ?: Firebase.initialize( | ||
context, | ||
FirebaseOptions( | ||
applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", | ||
apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", | ||
databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", | ||
storageBucket = "fir-kotlin-sdk.appspot.com", | ||
projectId = "fir-kotlin-sdk", | ||
gcmSenderId = "846484016111" | ||
) | ||
) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
firebase-messaging/src/androidMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@file:JvmName("android") | ||
package dev.gitlive.firebase.messaging | ||
|
||
import dev.gitlive.firebase.Firebase | ||
|
||
actual val Firebase.messaging: FirebaseMessaging | ||
get() = FirebaseMessaging(com.google.firebase.messaging.FirebaseMessaging.getInstance()) | ||
|
||
actual class FirebaseMessaging(val android: com.google.firebase.messaging.FirebaseMessaging) { | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
firebase-messaging/src/commonMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package dev.gitlive.firebase.messaging | ||
|
||
import dev.gitlive.firebase.Firebase | ||
import dev.gitlive.firebase.FirebaseApp | ||
|
||
/** Returns the [FirebaseMessaging] instance of the default [FirebaseApp]. */ | ||
expect val Firebase.messaging: FirebaseMessaging | ||
|
||
expect class FirebaseMessaging |
13 changes: 13 additions & 0 deletions
13
firebase-messaging/src/commonTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package dev.gitlive.firebase.messaging | ||
|
||
import dev.gitlive.firebase.Firebase | ||
import kotlin.test.Test | ||
import kotlin.test.assertNotNull | ||
|
||
abstract class FirebaseMessagingTest { | ||
|
||
@Test | ||
fun initialization() { | ||
assertNotNull(Firebase.messaging) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
firebase-messaging/src/iosMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package dev.gitlive.firebase.messaging | ||
|
||
import cocoapods.FirebaseMessaging.FIRMessaging | ||
import dev.gitlive.firebase.Firebase | ||
|
||
actual val Firebase.messaging: FirebaseMessaging | ||
get() = FirebaseMessaging(FIRMessaging.messaging()) | ||
|
||
actual class FirebaseMessaging(val ios: FIRMessaging) { | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
firebase-messaging/src/iosTest/kotlin/dev/gitlive/firebase/messaging/messaging.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package dev.gitlive.firebase.messaging | ||
|
||
class IOSFirebaseMessagingTest : FirebaseMessagingTest() |
9 changes: 9 additions & 0 deletions
9
firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/externals/messaging.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package dev.gitlive.firebase.messaging.externals | ||
|
||
import dev.gitlive.firebase.externals.FirebaseApp | ||
|
||
external fun getMessaging( | ||
app: FirebaseApp? = definedExternally, | ||
): Messaging | ||
|
||
external interface Messaging |
12 changes: 12 additions & 0 deletions
12
firebase-messaging/src/jsMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package dev.gitlive.firebase.messaging | ||
|
||
import dev.gitlive.firebase.Firebase | ||
import dev.gitlive.firebase.messaging.externals.Messaging | ||
import dev.gitlive.firebase.messaging.externals.getMessaging | ||
|
||
actual val Firebase.messaging: FirebaseMessaging | ||
get() = FirebaseMessaging(getMessaging()) | ||
|
||
actual class FirebaseMessaging(val js: Messaging) { | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
firebase-messaging/src/jvmMain/kotlin/dev/gitlive/firebase/messaging/messaging.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@file:JvmName("android") | ||
package dev.gitlive.firebase.messaging | ||
|
||
import dev.gitlive.firebase.Firebase | ||
|
||
actual val Firebase.messaging: FirebaseMessaging | ||
get() = TODO("Not yet implemented") | ||
|
||
actual class FirebaseMessaging |
Oops, something went wrong.