Skip to content

Commit

Permalink
Release 15.0.0 (#421)
Browse files Browse the repository at this point in the history
* Migration guide

* README

* Changelog

* Update CHANGELOG.md

* Update migration guide

* Fixes

* Update to 5.3.0 proxy, expose useUserPreferredLocale

* Update changelog
  • Loading branch information
rlepinski authored Mar 7, 2024
1 parent 57b8503 commit 7a04a8e
Show file tree
Hide file tree
Showing 11 changed files with 230 additions and 456 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Cordova Plugin Changelog

## Version 15.0.0 March 6, 2024
Major release with several breaking changes. Apps should use the migration guide to update [Migration Guide](https://github.com/urbanairship/urbanairship-cordova/blob/main/MIGRATION.md)

### Changes
- Requires cordova-android 12.0.0+, cordova-ios 7.0.0+, and Xcode 15.2+
- Updated to iOS SDK 17.8.0
- Updated to Android SDK 17.7.3
- Renamed package from `urbanairship-cordova` to `@ua/cordova-airship`
- Renamed package from `urbanairship-hms-cordova` to `@ua/cordova-airship-hms`
- Removed package from `urbanairship-accengage-cordova`
- Replaces `UAirship` with `Airship` as the root instance.
- Grouped functional apis under new components under the Airship instance: Airship.channel, Airship.push, Airship.push.ios, etc...
- Added types
- Added feature flag support
- Added new events for notification status


## Version 14.11.0 - January 11, 2024
Minor release that updates iOS SDK to 16.12.5 and removes an error message on Huawei devices that have the Play Store installed.

Expand Down
42 changes: 6 additions & 36 deletions DEV_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,19 @@

## Development

The example is set up to reference the modules using a yarn workspace.
Basic setup:

1) Install yarn and watchman, if necessary
1) Install everything

```
brew install yarn
npm run bootstrap
```

```
brew install watchman
```

2) Install modules

Execute the following command in the root directory

```
yarn install
```

3) Create a sample app

Execute the following command in the root directory.
That will create a sample in the parent directory with our cordova modules

```
yarn create-sample
```

4) Build and Run

Execute the following commands in the root directory to build and run the sample app for a given OS

```
yarn build-ios
yarn build-android
```
2) Create a sample app

```
yarn run-ios
yarn run-android
npm run create-sample
```

## Android limitations

- We need to stay compatible with Java 1.6. Try to not use `<>` and Strings in a switch statement.
When working with the plugin, you most likely will use the sample app. After making the changes you need you will copy the files back to the plugin.
373 changes: 185 additions & 188 deletions MIGRATION.md

Large diffs are not rendered by default.

231 changes: 7 additions & 224 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,229 +1,12 @@
# Urban Airship Cordova Plugin
# Cordova Airship Plugin

This plugin supports Cordova apps running on both iOS and Android.
A Cordova plugin for Airship's iOS and Android SDK.

### Resources:
- [Getting started guide](http://docs.urbanairship.com/platform/cordova/)
- [JSDocs](http://docs.urbanairship.com/reference/libraries/urbanairship-cordova/latest/)
- [Migration docs](MIGRATION.md)
### Resources

### Issues

Please visit http://support.urbanairship.com/ for any issues integrating or using this plugin.

### Requirements:
- cordova >= 9.0.0
- cordova-ios >= 6.1.0
- cordova-android >= 9.0.0
- cococapods >= 1.9

#### iOS:
- Xcode 13+
- [APNS Setup](https://docs.airship.com/platform/ios/getting-started/#apple-setup)

#### Android
- `minSdkVersion` 21+
- `compileSdkVersion` and `targetSdkVersion` 33+
- Gradle Plugin version 3.0.0+
- Java 8
- Android [FCM Setup](https://docs.airship.com/platform/android/getting-started/#fcm-setup)

##### Jetpack / AndroidX

This plugin requires modern Jetpack libraries (AndroidX). Enable AndroidX in your config.xml:

```
<preference name="AndroidXEnabled" value="true" />
```

### Quickstart

1. Install this plugin using Cordova CLI:

cordova plugin add urbanairship-cordova

2. *(Android Only)* Add a reference to your google-services.json file in the app's `config.xml`:
```
<platform name="android">
...
<resource-file src="google-services.json" target="app/google-services.json" />
</platform>
```

3. *(iOS Only)* Add your Apple Developer Account Team ID to the [build.json](https://cordova.apache.org/docs/en/latest/guide/platforms/ios/#using-buildjson):

{
"ios": {
"debug": {
"developmentTeam": "XXXXXXXXXX"
},
"release": {
"developmentTeam": "XXXXXXXXXX"
}
}
}
Your iOS builds will need to reference the build.json using Cordova's "--buildConfig" flag.

4. Initialize Urban Airship

Either call takeOff when the device is ready:

// TakeOff
UAirship.takeOff({
production: {
appKey: "<APP_KEY>",
appSecret: "<APP_SECRET>"
},
development: {
appKey: "<APP_KEY>",
appSecret: "<APP_SECRET>"
},
site: "US"
})

// Configure Android
UAirship.setAndroidNotificationConfig({
icon: "ic_notification",
largeIcon: "ic_notification_large",
accentColor: "#FF0000"
})

// Configure iOS
UAirship.setPresentationOptions(
UAirship.presentationOptions.sound | UAirship.presentationOptions.alert
)


Alternatively you can configure Urban Airship through config.xml and it will takeOff automatically.

<!-- Urban Airship app credentials -->
<preference name="com.urbanairship.production_app_key" value="Your Production App Key" />
<preference name="com.urbanairship.production_app_secret" value="Your Production App Secret" />
<preference name="com.urbanairship.development_app_key" value="Your Development App Key" />
<preference name="com.urbanairship.development_app_secret" value="Your Development App Secret" />

<!-- Optional -->
<!-- If the app is in production or not. If not set, Urban Airship will auto detect the mode. -->
<preference name="com.urbanairship.in_production" value="true | false" />

<!-- Urban Airship development log level defaults to debug -->
<preference name="com.urbanairship.development_log_level" value="none | error | warn | info | debug | verbose" />

<!-- Urban Airship production log level defaults to error -->
<preference name="com.urbanairship.production_log_level" value="none | error | warn | info | debug | verbose" />
* [Getting started guide](https://docs.airship.com/platform/mobile/setup/sdk/cordova/)
* [API docs](https://docs.airship.com/reference/libraries/urbanairship-cordova/latest/)

<!-- Enables/disables auto launching the message center when the corresponding push is opened. -->
<preference name="com.urbanairship.auto_launch_message_center" value="true | false" />

<!-- Urban Airship SDK Site (US or EU) defaults to US) -->
<preference name="com.urbanairship.site" value="US" />

<!-- Android Notification Settings -->
<preference name="com.urbanairship.notification_icon" value="ic_notification" />
<preference name="com.urbanairship.notification_large_icon" value="ic_notification_large" />
<preference name="com.urbanairship.notification_accent_color" value="#0000ff" />

<!-- iOS Foreround Presentation Options -->
<preference name="com.urbanairship.ios_foreground_notification_presentation_alert" value="true | false"/>
<preference name="com.urbanairship.ios_foreground_notification_presentation_badge" value="true | false"/>
<preference name="com.urbanairship.ios_foreground_notification_presentation_sound" value="true | false"/>

<!-- iOS Auto Clear Badge -->
<preference name="com.urbanairship.clear_badge_onlaunch" value="true | false" />

<!-- Deployment target must be >= iOS 11 -->
<preference name="deployment-target" value="11.0" />

`UrbanAirship.takeOff` can be called multiple times but any changes to the app credentials will not apply until the next app start.

5. Enable user notifications:

// Enable user notifications (will prompt the user to accept push notifications on iOS)
UAirship.setUserNotificationsEnabled(true, function (enabled) {
console.log("User notifications are enabled! Fire away!")
})

6. *(Optional)* Listen for events:

document.addEventListener("urbanairship.registration", onRegistration)
document.addEventListener("urbanairship.push", onPushReceived)
document.addEventListener("urbanairship.notification_opened", notificationOpened)
document.addEventListener("urbanairship.deep_link", handleDeepLink)

3. *(Optional)* Add platform-specific custom notification button groups resource files to config.xml:
```
<!-- Optional: include custom notification button groups in XML format -->
<platform name="android">
...
<resource-file src="ua_custom_notification_buttons.xml" target="app/src/main/res/xml/ua_custom_notification_buttons.xml" />
</platform>
...
<!-- Optional: include custom notification categories in plist format -->
<platform name="ios">
...
<resource-file src="UACustomNotificationCategories.plist" />
</platform>
```

#### Common CocoaPod Installation issues

Errors related to CocoaPods can be difficult to diagnose, because the `cordova` command line tool will often
exit with a status code without providing the necessary context. You may run into something like the following
when attempting to add the plugin to your ios project:

```
Installing "urbanairship-cordova" for ios
Failed to install 'urbanairship-cordova':Error: pod: Command failed with exit code 1
at ChildProcess.whenDone (/Users/xxxxx/xxxxx/test/platforms/ios/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:818:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
Error: pod: Command failed with exit code 1
```
This exit code can have a few underlying causes. One is that the local spec repo may be out of date, in which
case CocoaPods may be unable to find the version of the native SDK being installed. To resolve this, run the
command `pod repo update` and try re-adding the plugin. You would only need to run `pod repo update` if you
have the specs-repo already cloned on your machine through `pod setup`.

Another potential cause involves minimum deployment targets. The Airship iOS SDK supports the three most
recent iOS versions, and thus to install the plugin, your app must set its minimum deployment target accordingly,
in `config.xml`. As an example, see the deployment target in the provided [sample config](https://github.com/urbanairship/urbanairship-cordova/blob/main/config_sample.xml#L35).
Setting this value correctly should cause Cordova to generate a Podfile in the `ios` subdirectory of your
application with the same value for its platform version. If the minimum deployment target is not specified,
cordova will choose its own default value, which may be incorrect, and adding the plugin will fail with exit code 1.

There are also known issues in Cordova that can cause the platform version in `ios/Podfile` to be overwritten with
Cordova's default version. In both cases, doing the following will fix the issue:

* Update `config.xml` with the correct minimum deployment target, if needed.
* `cordova plugin remove urbanairship-cordova`
* `cordova platform remove ios`
* `cordova platform add ios`
* `cordova plugin add urbanairship-cordova`

### iOS Notification Service Extension

In order to take advantage of iOS notification attachments, such as images,
animated gifs, and video, you will need to create a [notification service extension](https://developer.apple.com/reference/usernotifications/unnotificationserviceextension/)
by following the [iOS Notification Service Extension Guide](https://docs.airship.com/platform/ios/getting-started/#notification-service-extension).

### Sample

A sample can be found in the Example directory.
### Issues

1. Add your UA credentials to the `config_sample.xml` file in the root directory and save.
2. Run the script with the command `./scripts/create_sample.sh PROJECT_PATH PROJECT_NAME`
3. cd to the newly-created project directory, e.g. sample/test
4. Build the platform you want to test.
* iOS
1. Build with command `cordova build ios --emulator`
2. After successful build, connect an iOS device to test
3. Run on device with command `cordova run ios --device --developmentTeam=XXXXXXXXXX`
* Please refer to "[Signing an App](https://cordova.apache.org/docs/en/latest/guide/platforms/ios/#signing-an-app)" for more information about code signing.
* Android
1. Build with command `cordova build android` in test directory
2. After successful build, connect an android device to test
3. Test with command `cordova run android`
Please visit https://support.airship.com/ for any issues integrating or using this plugin.
1 change: 1 addition & 0 deletions config_sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<allow-intent href="itms-apps:*" />
</platform>

<preference name="AndroidGradlePluginGoogleServicesEnabled" value="true" />
<preference name="AndroidXEnabled" value="true" />

<!-- Deployment target must be >= iOS 14 -->
Expand Down
2 changes: 1 addition & 1 deletion cordova-airship/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<source url="https://cdn.cocoapods.org/"/>
</config>
<pods use-frameworks="true">
<pod name="AirshipFrameworkProxy" spec="5.2.1" />
<pod name="AirshipFrameworkProxy" spec="5.3.0" />
</pods>
</podspec>
</platform>
Expand Down
4 changes: 2 additions & 2 deletions cordova-airship/src/android/AirshipCordova.kt
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class AirshipCordova : CordovaPlugin() {
"messageCenter#markMessageRead" -> callback.resolveResult(method) { proxy.messageCenter.markMessageRead(arg.requireString()) }
"messageCenter#deleteMessage" -> callback.resolveResult(method) { proxy.messageCenter.deleteMessage(arg.requireString()) }
"messageCenter#getUnreadMessageCount" -> callback.resolveResult(method) { proxy.messageCenter.getUnreadMessagesCount() }
"messageCenter#setAutoLaunch" -> callback.resolveResult(method) { proxy.messageCenter.setAutoLaunchDefaultMessageCenter(arg.requireBoolean()) }
"messageCenter#setAutoLaunchDefaultMessageCenter" -> callback.resolveResult(method) { proxy.messageCenter.setAutoLaunchDefaultMessageCenter(arg.requireBoolean()) }
"messageCenter#refreshMessages" -> callback.resolveDeferred(method) { resolveCallback ->
proxy.messageCenter.refreshInbox().addResultCallback {
if (it == true) {
Expand All @@ -253,7 +253,7 @@ class AirshipCordova : CordovaPlugin() {
// Preference Center
"preferenceCenter#display" -> callback.resolveResult(method) { proxy.preferenceCenter.displayPreferenceCenter(arg.requireString()) }
"preferenceCenter#getConfig" -> callback.resolvePending(method) { proxy.preferenceCenter.getPreferenceCenterConfig(arg.requireString()) }
"preferenceCenter#setAutoLaunch" -> callback.resolveResult(method) {
"preferenceCenter#setAutoLaunchPreferenceCenter" -> callback.resolveResult(method) {
val autoLaunchArgs = arg.requireList()
proxy.preferenceCenter.setAutoLaunchPreferenceCenter(
autoLaunchArgs.get(0).requireString(),
Expand Down
2 changes: 1 addition & 1 deletion cordova-airship/src/android/build-extras.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dependencies {
api "com.urbanairship.android:airship-framework-proxy:5.2.1"
api "com.urbanairship.android:airship-framework-proxy:5.3.0"
}

cdvPluginPostBuildExtras.push({
Expand Down
4 changes: 2 additions & 2 deletions cordova-airship/src/ios/AirshipCordova.swift
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public final class AirshipCordova: CDVPlugin {
try await AirshipProxy.shared.messageCenter.refresh()
return nil

case "messageCenter#setAutoLaunch":
case "messageCenter#setAutoLaunchDefaultMessageCenter":
AirshipProxy.shared.messageCenter.setAutoLaunchDefaultMessageCenter(
try command.requireBooleanArg()
)
Expand All @@ -462,7 +462,7 @@ public final class AirshipCordova: CDVPlugin {
preferenceCenterID: try command.requireStringArg()
)

case "preferenceCenter#setAutoLaunch":
case "preferenceCenter#setAutoLaunchPreferenceCenter":
let args = try command.requireArrayArg()
guard
args.count == 2,
Expand Down
6 changes: 6 additions & 0 deletions cordova-airship/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,12 @@ export interface AirshipConfig {
* The message center style plist path.
*/
messageCenterStyleConfig?: string;

/**
* If set to `true`, the SDK will use the preferred locale. Otherwise it will use the current locale.
* Defaults to false.
*/
useUserPreferredLocale?: boolean;
};

/**
Expand Down
Loading

0 comments on commit 7a04a8e

Please sign in to comment.