Skip to content

Commit

Permalink
fix(rtn-pn): make android module compatible with AGP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiSF committed Oct 20, 2023
1 parent 5b5391f commit 76ca2e8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
15 changes: 15 additions & 0 deletions packages/rtn-push-notification/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import com.android.Version

def agpVersion = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
def androidManifestPath = agpVersion >= 7 ? 'src/main/AndroidManifest.xml' : 'src/hasNamespace/AndroidManifest.xml'

buildscript {
def kotlin_version = rootProject.ext.has('kotlinVersion')
? rootProject.ext.get('kotlinVersion')
Expand Down Expand Up @@ -26,13 +31,23 @@ def getExtOrDefault(prop) {
}

android {
if (agpVersion >= 7) {
namespace 'com.amazonaws.amplify.rtnpushnotification'
}

compileSdkVersion getExtOrDefault('compileSdkVersion')

defaultConfig {
minSdkVersion getExtOrDefault('minSdkVersion')
targetSdkVersion getExtOrDefault('targetSdkVersion')
}

sourceSets {
main {
manifest.srcFile androidManifestPath
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amazonaws.amplify.rtnpushnotification">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application>
<activity
android:name=".PushNotificationLaunchActivity"
android:launchMode="singleInstance"
android:exported="false" />

<service android:name=".PushNotificationHeadlessTaskService" />

<service
android:name=".PushNotificationFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amazonaws.amplify.rtnpushnotification">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<application>
Expand Down

0 comments on commit 76ca2e8

Please sign in to comment.