diff --git a/CHANGELOG.md b/CHANGELOG.md index dff03e85..b6a584d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/DEV_README.md b/DEV_README.md index 6e1b9109..b09fd5a9 100644 --- a/DEV_README.md +++ b/DEV_README.md @@ -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. \ No newline at end of file +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. \ No newline at end of file diff --git a/MIGRATION.md b/MIGRATION.md index 80c4bdb6..a7f81f17 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1,213 +1,210 @@ # Migration Guide -## 7.x to 8.0.0 -Due to changes to the iOS SDK, iOS location services now require an additional dependency on -AirshipLocationKit. AirshipLocationKit can be linked to your project by adding the airship-location-cordova -plugin. See the [location](https://docs.airship.com/platform/cordova/location) documentation for more -details. +## 14.x to 15.x -Note: Version 8.0.0 requires the use of Cordova CLI version >= 9.0.1 and cordova-ios >= 5.0.1. +### Requirements -## 7.x to 7.5.0 +- cordova-android: 12.x +- cordova-ios: 7.x +- Xcode: 15.2+ -If you specified the minimum Android sdk version to be 16 (see 5.x to 6.0.0 migration below), please remove that from your config.xml or change it to be a minimum of 19. A minimum of 19 is required for new versions of Cordova. +### Config.xml Changes -## 6.x to 7.0.0 +In config.xml, you must set the min deployment target for iOS to 14 and enable swift support: -The method `setDisplayASAPEnabled` has been removed. - -## 6.x to 6.3.0 - -### Cocoapods - -This plugin uses cocoapods which is supported in cordova-ios 4.3.0. Ensure -cocoapods is installed and the pod repo is updated via `pod repo update`. If -using Xcode directly, open the xcworkspace instead of the xcodeproj. - -## 5.x to 6.0.0 - -### Android Minimum SDK Version - -Urban Airship Android 8.0.0 SDK requires the minimum sdk version to be 16. -Modify the config.xml file to contain: - - - - - -### Location Changes - -The method `recordCurrentLocation` has been removed. - -## 4.x to 5.0.0 - - -All functions now take an optional failure callback. - - -### Run Action - -The method ``runAction`` now returns the result's value in the success callback -and the result's error in the failure callback. - -4.x example: - - UAirship.runAction("some_action", "some value", function (result) { - if (result.error) { - console.log("action failed": + result.error); - } else { - console.log("action finished": + result.value); - } - }); - -5.x example: - - UAirship.runAction("some_action", "some value", function (value) { - console.log("action finished": + value); - }, function (error) { - console.log("action failed": + error); - }); - - -## 3.6.0 to 4.0.0 - -### Installation changes: - -Now requires Cordova 5.4.0+, Cordova Android 4.1.0, and Cordova iOS 3.9.0. -The iOS Airship library is bitcode enabled for Xcode 7+. - -## 2.8.x to 3.0.0 - -### Plugin Access: - -The plugin is now attached to the window as `UAirship` instead of `PushNotification`. - -### Installation changes - -Plugin ID has been changed from `com.urbanairship.phonegap.PushNotification` to `com.urbanairship.cordova`. The old version -may need to be uninstalled manually before updating to the new version. - -### Push Changes - -To enable or disable push, use `setUserNotificationsEnabled` instead of `enablePush` or `disablePush`. The app will -continue to not prompt for push until user notifications is enabled. `registerNotificationTypes` has been renamed to -`setNotificationTypes`. Its only required to be called if the app only wants to register for specific types of notifications. -If it is not set, the app will register for all types - alert, sound, and vibrate. - -The method `getPushID` has been replaced with `getChannelID`. It now returns the channel ID for both Android and iOS. - -To access the launch notification, call `getLaunchNotification` instead of `getIncoming`. `getLaunchNotification` no longer -clears the notification on first access, instead it takes a flag as the first parameter to clear the notification or not. - -Example: - - UAirship.getLaunchNotification(true, callback) - - -Fetching tags no longer returns an object with a tag array, instead it now returns just the tags. - -Example: - - UAirship.getTags(function(tags) { - tags.forEach(function(tag) { - console.log("tag: " + tag); - }) - }) - - -### Location Changes: - -To enable or disable location, use `setLocationEnabled` instead of `enableLocation` or `disableLocation`. Similarly with -background location, use `setBackgroundLocationEnabled`. - - -## 2.5.x to 2.6.0 - -### Android Installation changes: - -Android plugin now requires Google Play Services and the Android Support v4 library. If the plugin was manually installed, -remove the old urbanairship.jar file and follow the manual setup instructions again in the README. - -The custom_rules.xml file in the root of the android project needs to be deleted due to bug https://code.google.com/p/android/issues/detail?id=23271 and https://issues.apache.org/jira/browse/CB-7675. - -## 2.3.x to 2.4.0 +``` + + -### Installation changes: + + +``` -For iOS, make sure you update your iOS project to Cordova iOS version 3.4.1 before installing the phonegap-ua-push plugin. -For example: +For Android to enable FCM, enable the Google Services plugin: ``` -1. cordova platform update ios -iOS project is now at version 3.4.1 -2. phonegap local plugin add https://github.com/urbanairship/phonegap-ua-push.git + ``` -## 2.2.x to 2.3.0 - -### Config Changes: - -In 2.2.x, push was enabled by default and would prompt the user to allow push before the application -was ready to prompt the user for push. In 2.3.0, push is now disabled by default and will be enabled -when enablePush is called in javascript. This allows the application to determine when to -prompt the user for push. - -To keep the old 2.2.x behavior, you can set the config option 'com.urbanairship.enable_push_onlaunch' -to 'true' in the config.xml. +### Package Changes + +The npm packages are now published under new names: + +| 14.x | 15.x | Notes | +|--------------------------------|-------------------------|--------------------------------------------------------------------------------------------------| +| urbanairship-cordova | @ua/cordova-airship | The plugin id is `cordova-airship`. | +| urbanairship-cordova-hms | @ua/cordova-airhsip-hms | The plugin id is `cordova-airship-hms`. | +| urbanairship-accengage-cordova | removed | Package is no longer needed. It was only needed during the transition from Accengage to Airship. | + + +### API + +The public API has been rewritten. Most methods have a one off replacement. See the table below for the method mapping. + +| 14.x | 15.x | Notes | +|---------------------------------------------------|---------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------| +| UAirship.takeOff | Airship.takeOff | The option `messageCenterStyleConfig` moved to AirshipConfig.ios.messageCenterStyleConfig. | +| UAirship.setAndroidNotificationConfig | Airship.push.android.setNotificationConfig | You can now also android notification config during takeOff | +| UAirship.setAutoLaunchDefaultMessageCenter | Airship.messageCenter.setAutoLaunchDefaultMessageCenter | | +| UAirship.displayMessageCenter | Airship.messageCenter.display | If `setAutoLaunchDefaultMessageCenter` is enabled, this will show a message center UI. If no, it will generate events. | +| UAirship.dismissMessageCenter | Airship.messageCenter.dismiss | | +| UAirship.dismissInboxMessage | Airship.messageCenter.dismiss | | +| UAirship.getInboxMessages | Airship.messageCenter.getMessages | | +| UAirship.markInboxMessageRead | Airship.messageCenter.markMessageRead | | +| UAirship.deleteInboxMessage | Airship.messageCenter.deleteMessage | | +| UAirship.displayInboxMessage | Airship.messageCenter.showMessageView | | +| UAirship.refreshInbox | Airship.messageCenter.refreshMessages | | +| UAirship.setUserNotificationsEnabled | Airship.push.setUserNotificationsEnabled | | +| UAirship.isUserNotificationsEnabled | Airship.push.isUserNotificationsEnabled | | +| UAirship.enableUserNotifications | Airship.push.enableUserNotifications | | +| UAirship.isAppNotificationsEnabled | Airship.push.getNotificationStatus | Use the flag `areNotificationsAllowed` on the status object | +| UAirship.isQuietTimeEnabled | Airship.push.isQuietTimeEnabled | | +| UAirship.setQuietTimeEnabled | Airship.push.setQuietTimeEnabled | | +| UAirship.isInQuietTime | No replacement | If needed please file a github issue with usage. | +| UAirship.setQuietTime | Airship.push.setQuietTime | API now takes an object with startHour, endHour, startMinute, endMinute | +| UAirship.getQuietTime | Airship.push.getQuietTime | | +| UAirship.clearNotification | Airship.push.clearNotification | | +| UAirship.clearNotifications | Airship.push.clearNotifications | | +| UAirship.getActiveNotifications | Airship.push.getActiveNotifications | | +| UAirship.setAutobadgeEnabled | Airship.push.ios.setAutobadgeEnabled | | +| UAirship.setBadgeNumber | Airship.push.ios.setBadgeNumber | | +| UAirship.setBadgeNumber | Airship.push.ios.setBadgeNumber | | +| UAirship.getBadgeNumber | Airship.push.ios.getBadgeNumber | | +| UAirship.resetBadge | Airship.push.ios.resetBadge | | +| UAirship.setNotificationTypes | Airship.push.ios.setNotificationOptions | | +| UAirship.setPresentationOptions | Airship.push.ios.setForegroundPresentationOptions | | +| UAirship.setAndroidForegroundNotificationsEnabled | Airship.push.android.setForegroundNotificationsEnabled | | +| UAirship.isSoundEnabled | No replacement | Use notification categories/channel instead | +| UAirship.setSoundEnabled | No replacement | Use notification categories/channel instead | +| UAirship.isVibrateEnabled | No replacement | Use notification categories/channel instead | +| UAirship.setVibrateEnabled | No replacement | Use notification categories/channel instead | +| UAirship.setAnalyticsEnabled | Airship.privacyManager.enable/disable | Enable/disable "analytics" flag on privacy manager | +| UAirship.isAnalyticsEnabled | Airship.privacyManager.isFeaturesEnabled("analytics") | | +| UAirship.setAssociatedIdentifier | Airship.analytics.setAssociatedIdentifier | | +| UAirship.addCustomEvent | Airship.analytics.addCustomEvent | The field `name` is now `eventName`, `value` is `eventValue`, `properties` can be any valid json object. | +| UAirship.trackScreen | Airship.analytics.trackScreen | | +| UAirship.getChannelID | Airship.channel.getChannelId | | +| UAirship.getTags | Airship.channel.getTags | | +| UAirship.setTags | Airship.channel.editTags | Use the editor to add and remove tags | +| UAirship.editChannelTagGroups | Airship.channel.editTagGroups | | +| UAirship.editChannelAttributes | Airship.channel.editAttributes | | +| UAirship.editChannelSubscriptionLists | Airship.channel.editSubscriptionLists | | +| UAirship.getChannelSubscriptionLists | Airship.channel.getSubscriptionLists | | +| UAirship.getAlias | Airship.contact.getNamedUserId | | +| UAirship.setAlias | Airship.contact.identify | | +| UAirship.getNamedUser | Airship.contact.getNamedUserId | | +| UAirship.setNamedUser | Airship.contact.identify/reset | Use identify to set the named user, reset to clear it | +| UAirship.editNamedUserTagGroups | Airship.contact.editTagGroups | | +| UAirship.editNamedUserAttributes | Airship.contact.editAttributes | | +| UAirship.editContactSubscriptionLists | Airship.contact.editSubscriptionLists | | +| UAirship.getContactSubscriptionLists | Airship.contact.getSubscriptionLists | | +| UAirship.getLaunchNotification | No replacement | Use the Airship.push.onNotificationResponse listener | +| UAirship.getDeepLink | No replacement | Use the Airship.onDeepLink listener | +| UAirship.runAction | Airship.actions.run | | +| UAirship.enableFeature | Airship.privacyManager.enableFeature | Feature constants, see below for more info. | +| UAirship.disableFeature | Airship.privacyManager.disableFeature | Feature constants, see below for more info. | +| UAirship.setEnabledFeatures | Airship.privacyManager.setEnabledFeatures | Feature constants, see below for more info. | +| UAirship.getEnabledFeatures | Airship.privacyManager.getEnabledFeatures | Feature constants, see below for more info. | +| UAirship.isFeatureEnabled | Airship.privacyManager.isFeatureEnabled | Feature constants, see below for more info. | +| UAirship.openPreferenceCenter | Airship.preferenceCenter.display | | +| UAirship.getPreferenceCenterConfig | Airship.preferenceCenter.getConfig | | +| UAirship.setUseCustomPreferenceCenterUi | Airship.preferenceCenter.setAutoLaunchDefaultPreferenceCenter | | +| UAirship.setCurrentLocale | Airship.locale.setLocaleOverride | | +| UAirship.getCurrentLocale | Airship.locale.getLocale | | +| UAirship.clearLocale | Airship.locale.clearLocaleOverride | | +| UAirship.reattach | No replacement | Events are no longer sent on the document. See events for replacements | + +### Privacy Manager Flags + +The flag constants are no longer all uppercase and some options have been removed. The 15.x flags are: -## 2.1.x to 2.2.0 - -### Installation changes: - -The PushNotification.js no longer sets the PushNotification plugin at window.plugins.PushNotification -and instead uses module.exports. Instead of including the PushNotification.js script, at the top of the -javascript file that the plugin is being used, include the following: - - var PushNotification = require('') - -**Note:** If you are using automatic integration, the required step is done automatically. +``` +/** + * Enum of authorized Features. + */ +export enum Feature { + InAppAutomation = 'in_app_automation', + MessageCenter = 'message_center', + Push = 'push', + Analytics = 'analytics', + TagsAndAttributes = 'tags_and_attributes', + Contacts = 'contacts', +} +``` +### Events -### Event changes +Events are no longer sent as document events. Events are also now queued up until a listener is added, so there is no longer a need to return `launchNotification` or `deepLink` since its now possible for the app to receive those when ready. -Registration events and incoming push events are now standard dom events. +| 14.x | 15.x | Notes | +|--------------------------------------------------------------------------------|-----------------------------------------------|-------------------------------------------------| +| document.addEventListener("urbanairship.deep_link", callback) | Airship.onDeepLink(callback) | | +| document.addEventListener("urbanairship.registration", callback) | Airship.channel.onChannelCreated(callback) | For channel ID. Use `event.channelId` | +| document.addEventListener("urbanairship.registration", callback) | Airship.push.onPushTokenReceived(callback) | For push token. Use `event.pushToken` | +| document.addEventListener("urbanairship.push", callback) | Airship.push.onPushReceived(callback) | The event has changed, see below for more info. | +| document.addEventListener("urbanairship.notification_opened", callback) | Airship.push.onNotificationReceived(callback) | The event has changed, see below for more info. | +| document.addEventListener("urbanairship.notification_opt_in_status", callback) | Airship.onNotificationStatusChanged(callback) | The event has changed, see below for more info. | +| document.addEventListener("urbanairship.inbox_updated", callback) | Airship.messageCenter.onUpdated(callback) | | +| document.addEventListener("urbanairship.show_inbox", callback) | Airship.messageCenter.onDisplay(callback) | | +| document.addEventListener("urbanairship.open_preference_center", callback) | Airship.preferenceCenter.onDisplay(callback) | | -PushNotification.registerEvents is now removed. The "registration" and "push" events -can now be accessed by listening for events on the document: +#### Push Received -Events: +The push payload is now grouped under the `pushPayload` field. The old `message` field has been renamed to `alert` (`pushPayload.alert`). - Name: 'urbanairship.registration' +#### Push Response - Event object: - { - error: , - pushID: - } - - Name: 'urbanairship.push' - - Event object: - { - message: , - extras: - } +The push payload is now grouped under the `pushPayload` field. The old `message` field has been renamed to `alert` (`pushPayload.alert`). The field `actionID` has been renamed to `actionId`. -Example: - document.addEventListener("urbanairship.registration", function (event) { - if (event.error) { - console.log('there was an error registering for push notifications'); - } else { - console.log("Registered with ID: " + event.pushID); - } - }, false) - - document.addEventListener("urbanairship.push", function (event) { - console.log("Incoming push: " + event.message) - }, false) +#### Notification Opt In Status Event +Notification status event now provides an object with several flags that you can use to determine the exact reason why the device is opted out: -**Note:** If your application supports Android and it listens to any of the events, you should start -listening for events on both 'deviceReady' and 'resume' and stop listening for events on 'pause'. -This will prevent the events from being handled in the background. +``` +/** + * Push notification status. + */ +export interface PushNotificationStatus { + /** + * If user notifications are enabled on [Airship.push]. + */ + isUserNotificationsEnabled: boolean; + + /** + * If notifications are allowed at the system level for the application. + */ + areNotificationsAllowed: boolean; + + /** + * If the push feature is enabled on [Airship.privacyManager]. + */ + isPushPrivacyFeatureEnabled: boolean; + + /* + * If push registration was able to generate a token. + */ + isPushTokenRegistered: boolean; + + /* + * If Airship is able to send and display a push notification. + */ + isOptedIn: boolean; + + /* + * Checks for isUserNotificationsEnabled, areNotificationsAllowed, and isPushPrivacyFeatureEnabled. If this flag + * is true but `isOptedIn` is false, that means push token was not able to be registered. + */ + isUserOptedIn: boolean; +} + +/** + * Event fired when the notification status changes. + */ +export interface PushNotificationStatusChangedEvent { + /** + * The push notification status. + */ + status: PushNotificationStatus +} +``` \ No newline at end of file diff --git a/README.md b/README.md index 1f74bd87..fe09ab6f 100644 --- a/README.md +++ b/README.md @@ -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: - -``` - -``` - -### 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`: -``` - - ... - - -``` - -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: "", - appSecret: "" - }, - development: { - appKey: "", - appSecret: "" - }, - 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. - - - - - - - - - - - - - - - - +* [Getting started guide](https://docs.airship.com/platform/mobile/setup/sdk/cordova/) +* [API docs](https://docs.airship.com/reference/libraries/urbanairship-cordova/latest/) - - - - - - - - - - - - - - - - - - - - - - - `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: -``` - - - ... - - - - ... - - - - ... - - -``` - -#### 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. diff --git a/config_sample.xml b/config_sample.xml index c7bffa47..bdea56cc 100644 --- a/config_sample.xml +++ b/config_sample.xml @@ -36,6 +36,7 @@ + diff --git a/cordova-airship/plugin.xml b/cordova-airship/plugin.xml index 8a8f31de..0b70137c 100644 --- a/cordova-airship/plugin.xml +++ b/cordova-airship/plugin.xml @@ -133,7 +133,7 @@ - + diff --git a/cordova-airship/src/android/AirshipCordova.kt b/cordova-airship/src/android/AirshipCordova.kt index ca35f21d..b2e92ff5 100644 --- a/cordova-airship/src/android/AirshipCordova.kt +++ b/cordova-airship/src/android/AirshipCordova.kt @@ -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) { @@ -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(), diff --git a/cordova-airship/src/android/build-extras.gradle b/cordova-airship/src/android/build-extras.gradle index e037ae19..c8cdd6cf 100644 --- a/cordova-airship/src/android/build-extras.gradle +++ b/cordova-airship/src/android/build-extras.gradle @@ -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({ diff --git a/cordova-airship/src/ios/AirshipCordova.swift b/cordova-airship/src/ios/AirshipCordova.swift index 79a157ca..fd6d5346 100644 --- a/cordova-airship/src/ios/AirshipCordova.swift +++ b/cordova-airship/src/ios/AirshipCordova.swift @@ -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() ) @@ -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, diff --git a/cordova-airship/types/index.d.ts b/cordova-airship/types/index.d.ts index 40bd1ff8..4563de5d 100644 --- a/cordova-airship/types/index.d.ts +++ b/cordova-airship/types/index.d.ts @@ -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; }; /** diff --git a/cordova-airship/www/Airship.js b/cordova-airship/www/Airship.js index a41b7159..ff0573b7 100644 --- a/cordova-airship/www/Airship.js +++ b/cordova-airship/www/Airship.js @@ -579,8 +579,8 @@ airship.preferenceCenter.getConfig = function (preferenceCenterId, success, fail } airship.preferenceCenter.setAutoLaunchDefaultPreferenceCenter = function (preferenceCenterId, autoLaunch, success, failure) { - argscheck.checkArgs('s*FF', 'Airship.preferenceCenter.getConfig', arguments) - perform("preferenceCenter#getConfig", [preferenceCenterId, !!autoLaunch], success, failure) + argscheck.checkArgs('s*FF', 'Airship.preferenceCenter.setAutoLaunchDefaultPreferenceCenter', arguments) + perform("preferenceCenter#setAutoLaunchDefaultPreferenceCenter", [preferenceCenterId, !!autoLaunch], success, failure) } airship.preferenceCenter.onDisplay = function (callback) {