Skip to content

Commit

Permalink
Release 2.3.0 (#20)
Browse files Browse the repository at this point in the history
* Update plugin to proxy 10.0.0

* Wire up lu/la

* Changelog

* Update changelog
  • Loading branch information
rlepinski authored Oct 7, 2024
1 parent 635ce25 commit dbc4703
Show file tree
Hide file tree
Showing 49 changed files with 1,279 additions and 100 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Capacitor Plugin Changelog

## Version 2.3.0 - October 7, 2024

Minor release that updates to latest SDK versions and adds support for iOS Live Activities & Android Live Updates.

### Changes
- Updated Airship Android SDK to [18.3.2](https://github.com/urbanairship/android-library/releases/tag/18.3.2)
- Updated Airship iOS SDK to [18.10.0](https://github.com/urbanairship/ios-library/releases/tag/18.10.0)
- Added new APIs to manage [iOS Live Activities](https://docs.airship.com/platform/mobile/ios-live-activities/)
- Added new APIs to manage [Android Live Updates](https://docs.airship.com/platform/mobile/android-live-updates/)
- Added a new [Plugin Extenders](http://localhost:1313/platform/mobile/setup/sdk/capacitor/#extending-airship) to modify the native Airship SDK after takeOff


## Version 2.2.0 September 25, 2024
Minor release that updates the iOS SDK to 18.9.2 and adds the method `Airship.messageCenter.showMessageCenter(messageId?: string)` that can be used to show the OOTB Message Center UI even if auto launching Message Center is disabled. This new functionality is useful if the application needs to route the user in the app before processing the display event while still being able to use the OOTB UI.

Expand Down
10 changes: 2 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,17 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", branch: "main"),
.package(url: "https://github.com/urbanairship/airship-mobile-framework-proxy.git", from: "8.1.0")
.package(url: "https://github.com/urbanairship/airship-mobile-framework-proxy.git", from: "10.0.0")
],
targets: [
.target(
name: "UaCapacitorAirshipPlugin",
name: "UaCapacitorAirship",
dependencies: [
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm"),
.product(name: "AirshipFrameworkProxy", package: "airship-mobile-framework-proxy")
],
path: "ios/Plugin"
),
.target(
name: "UaCapacitorAirship",
dependencies: [.target(name: "UaCapacitorAirshipPlugin")],
path: "ios/Bootloader",
publicHeadersPath: "Public"
)
]
)
14 changes: 2 additions & 12 deletions UaCapacitorAirship.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ Pod::Spec.new do |s|
s.ios.deployment_target = '14.0'
s.dependency 'Capacitor'
s.swift_version = '5.1'
s.dependency "AirshipFrameworkProxy", "8.1.0"
s.default_subspecs = ["Bootloader", "Plugin"]


s.subspec "Bootloader" do |bootloader|
bootloader.source_files = 'ios/Bootloader/**/*.{swift,h,m,c,cc,mm,cpp}'
end


s.subspec "Plugin" do |plugin|
plugin.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
end
s.dependency "AirshipFrameworkProxy", "10.0.0"
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
end
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ext {
airshipProxyVersion = project.hasProperty('airshipProxyVersion') ? rootProject.ext.airshipProxyVersion : '8.1.0'
airshipProxyVersion = project.hasProperty('airshipProxyVersion') ? rootProject.ext.airshipProxyVersion : '10.0.0'
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
package com.airship.capacitor

object AirshipCapacitorVersion {
var version = "2.2.0"
var version = "2.3.0"
}
30 changes: 30 additions & 0 deletions android/src/main/java/com/airship/capacitor/AirshipPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.urbanairship.android.framework.proxy.events.EventEmitter
import com.urbanairship.android.framework.proxy.proxies.AirshipProxy
import com.urbanairship.android.framework.proxy.proxies.EnableUserNotificationsArgs
import com.urbanairship.android.framework.proxy.proxies.FeatureFlagProxy
import com.urbanairship.android.framework.proxy.proxies.LiveUpdateRequest
import com.urbanairship.json.JsonList
import com.urbanairship.json.JsonMap
import com.urbanairship.json.JsonSerializable
Expand Down Expand Up @@ -246,6 +247,35 @@ class AirshipPlugin : Plugin() {
}
}

// Live Update
"liveUpdateManager#list" -> call.resolveSuspending(method) {
val request = LiveUpdateRequest.List.fromJson(arg)
proxy.liveUpdateManager.list(request)
}

"liveUpdateManager#listAll" -> call.resolveSuspending(method) {
proxy.liveUpdateManager.listAll()
}

"liveUpdateManager#start" -> call.resolveSuspending(method) {
val request = LiveUpdateRequest.Start.fromJson(arg)
proxy.liveUpdateManager.start(request)
}

"liveUpdateManager#update" -> call.resolveSuspending(method) {
val request = LiveUpdateRequest.Update.fromJson(arg)
proxy.liveUpdateManager.update(request)
}

"liveUpdateManager#end" -> call.resolveSuspending(method) {
val request = LiveUpdateRequest.End.fromJson(arg)
proxy.liveUpdateManager.end(request)
}

"liveUpdateManager#clearAll" -> call.resolveSuspending(method) {
proxy.liveUpdateManager.clearAll()
}

else -> call.reject("Not implemented")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import com.urbanairship.json.JsonValue

class CapacitorAutopilot : BaseAutopilot() {

override fun onAirshipReady(airship: UAirship) {
super.onAirshipReady(airship)

override fun onReady(context: Context, airship: UAirship) {
Log.i("CapacitorAutopilot", "onAirshipReady")
airship.analytics.registerSDKExtension(Extension.CAPACITOR, AirshipCapacitorVersion.version)
}
Expand Down
7 changes: 7 additions & 0 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {

kotlinOptions {
jvmTarget = '17'
}

namespace "com.example.plugin"
compileSdk rootProject.ext.compileSdkVersion
defaultConfig {
Expand Down
1 change: 1 addition & 0 deletions example/android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies {
implementation project(':capacitor-camera')
implementation project(':capacitor-splash-screen')
implementation project(':ua-capacitor-airship')
implementation 'androidx.core:core-ktx:1.13.1'

}

Expand Down
6 changes: 6 additions & 0 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">


<meta-data
android:name="com.urbanairship.plugin.extender"
android:value="com.example.plugin.AirshipExtender" />


<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name=".MainActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.example.plugin

import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.os.Build
import androidx.annotation.Keep
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.urbanairship.UAirship
import com.urbanairship.android.framework.proxy.AirshipPluginExtender
import com.urbanairship.json.requireField
import com.urbanairship.liveupdate.LiveUpdate
import com.urbanairship.liveupdate.LiveUpdateEvent
import com.urbanairship.liveupdate.LiveUpdateManager
import com.urbanairship.liveupdate.LiveUpdateResult
import com.urbanairship.liveupdate.SuspendLiveUpdateNotificationHandler


@Keep
public final class AirshipExtender: AirshipPluginExtender {
override fun onAirshipReady(context: Context, airship: UAirship) {
LiveUpdateManager.shared().register("Example", ExampleLiveUpdateHandler())
}
}

public final class ExampleLiveUpdateHandler: SuspendLiveUpdateNotificationHandler() {
override suspend fun onUpdate(
context: Context,
event: LiveUpdateEvent,
update: LiveUpdate
): LiveUpdateResult<NotificationCompat.Builder> {

if (event == LiveUpdateEvent.END) {
// Dismiss the live update on END. The default behavior will leave the Live Update
// in the notification tray until the dismissal time is reached or the user dismisses it.
return LiveUpdateResult.cancel()
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val importance = NotificationManager.IMPORTANCE_DEFAULT
val channel = NotificationChannel("emoji-example", "Emoji example", importance)
channel.description = "Emoji example"
NotificationManagerCompat.from(context).createNotificationChannel(channel)
}

val launchIntent = context.packageManager
.getLaunchIntentForPackage(context.packageName)
?.addCategory(update.name)
?.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP)
?.setPackage(null)

val contentIntent = PendingIntent.getActivity(
context, 0, launchIntent, PendingIntent.FLAG_IMMUTABLE
)

val notification = NotificationCompat.Builder(context, "emoji-example")
.setSmallIcon(R.drawable.ic_notification)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setCategory(NotificationCompat.CATEGORY_EVENT)
.setContentTitle("Example Live Update")
.setContentText(update.content.requireField<String>("emoji"))
.setContentIntent(contentIntent)

return LiveUpdateResult.ok(notification)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF">
<group android:scaleX="0.92"
android:scaleY="0.92"
android:translateX="0.96"
android:translateY="0.96">
<path
android:pathData="M17.6,11.48 L19.44,8.3a0.63,0.63 0,0 0,-1.09 -0.63l-1.88,3.24a11.43,11.43 0,0 0,-8.94 0L5.65,7.67a0.63,0.63 0,0 0,-1.09 0.63L6.4,11.48A10.81,10.81 0,0 0,1 20L23,20A10.81,10.81 0,0 0,17.6 11.48ZM7,17.25A1.25,1.25 0,1 1,8.25 16,1.25 1.25,0 0,1 7,17.25ZM17,17.25A1.25,1.25 0,1 1,18.25 16,1.25 1.25,0 0,1 17,17.25Z"
android:fillColor="#FF000000"/>
</group>
</vector>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
google()
gradlePluginPortal()
mavenCentral()
}

ext {
kotlinVersion = '1.9.10'
kotlin_version = '1.9.10'

}

dependencies {
classpath 'com.android.tools.build:gradle:8.2.1'
classpath 'com.google.gms:google-services:4.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit dbc4703

Please sign in to comment.