> contactSubscriptionList) {
- try {
- callbackContext.success(new JSONObject(JsonValue.wrap(contactSubscriptionList, JsonMap.EMPTY_MAP.toJsonValue()).toString()));
- } catch (JSONException e) {
- callbackContext.error(e.getMessage());
- }
- }
- });
- }
-
- /**
- * Runs an Urban Airship action.
- *
- * Expected arguments: String - action name, * - the action value
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- */
- private void runAction(@NonNull JSONArray data, @NonNull final CallbackContext callbackContext) throws JSONException {
- final String actionName = data.getString(0);
- final Object actionValue = data.opt(1);
-
- ActionRunRequest.createRequest(actionName)
- .setValue(actionValue)
- .run(new ActionCompletionCallback() {
- @Override
- public void onFinish(@NonNull ActionArguments arguments, @NonNull ActionResult result) {
-
- if (result.getStatus() == ActionResult.STATUS_COMPLETED) {
-
- /*
- * We are wrapping the value in an object to preserve the type of data
- * the action returns. CallbackContext.success does not allow all types.
- * The value will be pulled out in the UAirship.js file before passing
- * it back to the user.
- */
-
- Map resultMap = new HashMap();
- resultMap.put("value", result.getValue().toJsonValue());
-
- try {
- callbackContext.success(new JSONObject(resultMap.toString()));
- } catch (JSONException e) {
- callbackContext.error("Failed to convert action results: " + e.getMessage());
- }
- } else {
- callbackContext.error(createActionErrorMessage(actionName, result));
- }
- }
- });
- }
-
- /**
- * Helper method to create the action run error message.
- *
- * @param name The name of the action.
- * @param result The action result.
- * @return The action error message.
- */
- private static String createActionErrorMessage(String name, ActionResult result) {
- switch (result.getStatus()) {
- case ActionResult.STATUS_ACTION_NOT_FOUND:
- return String.format("Action %s not found", name);
- case ActionResult.STATUS_REJECTED_ARGUMENTS:
- return String.format("Action %s rejected its arguments", name);
- case ActionResult.STATUS_EXECUTION_ERROR:
- if (result.getException() != null) {
- return result.getException().getMessage();
- }
- case ActionResult.STATUS_COMPLETED:
- return "";
- }
-
- return String.format("Action %s failed with unspecified error", name);
- }
-
- /**
- * Helper method to apply tag operations to a TagGroupsEditor.
- *
- * @param editor The editor.
- * @param operations The tag operations.
- */
- private static void applyTagGroupOperations(TagGroupsEditor editor, JSONArray operations) throws JSONException {
- for (int i = 0; i < operations.length(); i++) {
- JSONObject operation = operations.getJSONObject(i);
-
- JSONArray tags = operation.getJSONArray("tags");
- String group = operation.getString("group");
- String operationType = operation.getString("operation");
-
- HashSet tagSet = new HashSet();
- for (int j = 0; j < tags.length(); j++) {
- tagSet.add(tags.getString(j));
- }
-
- if (tagSet.isEmpty()) {
- continue;
- }
-
- if ("add".equals(operationType)) {
- editor.addTags(group, tagSet);
- } else if ("remove".equals(operationType)) {
- editor.removeTags(group, tagSet);
- }
- }
- }
-
- /**
- * Displays the message center.
- *
- * @param data The call data. The message ID is expected to be the first entry.
- * @param callbackContext The callback context.
- */
- private void displayMessageCenter(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) {
- String messageId = data.optString(0);
-
- PluginLogger.debug("Displaying Message Center");
- if (!UAStringUtil.isEmpty(messageId)) {
- Intent intent = new Intent(cordova.getActivity(), com.urbanairship.cordova.CustomMessageCenterActivity.class)
- .setAction(MessageCenter.VIEW_MESSAGE_INTENT_ACTION)
- .setPackage(cordova.getActivity().getPackageName())
- .setData(Uri.fromParts(MessageCenter.MESSAGE_DATA_SCHEME, messageId, null))
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
-
- cordova.getActivity().startActivity(intent);
- } else {
- Intent intent = new Intent(cordova.getActivity(), com.urbanairship.cordova.CustomMessageCenterActivity.class)
- .setPackage(cordova.getActivity().getPackageName())
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
-
- cordova.getActivity().startActivity(intent);
- }
- callbackContext.success();
- }
-
- /**
- * Dismiss the message center.
- *
- * @param data The call data. The message ID is expected to be the first entry.
- * @param callbackContext The callback context.
- */
- private void dismissMessageCenter(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) {
- PluginLogger.debug("Dismissing Message Center");
- Intent intent = new Intent(cordova.getActivity(), com.urbanairship.cordova.CustomMessageCenterActivity.class)
- .setAction(com.urbanairship.cordova.CustomMessageCenterActivity.CLOSE_INTENT_ACTION);
-
- cordova.getActivity().startActivity(intent);
-
- callbackContext.success();
- }
-
- /**
- * Deletes an inbox message.
- *
- * @param data The call data. The message ID is expected to be the first entry.
- * @param callbackContext The callback context.
- * @throws JSONException
- */
- private void deleteInboxMessage(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- String messageId = data.getString(0);
- Message message = MessageCenter.shared().getInbox().getMessage(messageId);
-
- if (message == null) {
- callbackContext.error("Message not found: " + messageId);
- return;
- }
-
- message.delete();
- callbackContext.success();
- }
-
- /**
- * Marks an inbox message read.
- *
- * @param data The call data. The message ID is expected to be the first entry.
- * @param callbackContext The callback context.
- * @throws JSONException
- */
- private void markInboxMessageRead(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- String messageId = data.getString(0);
- Message message = MessageCenter.shared().getInbox().getMessage(messageId);
-
- if (message == null) {
- callbackContext.error("Message not found: " + messageId);
- return;
- }
-
- message.markRead();
- callbackContext.success();
- }
-
- /**
- * Gets the inbox listing.
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- * @throws JSONException
- */
- private void getInboxMessages(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- JSONArray messagesJson = new JSONArray();
-
- for (Message message : MessageCenter.shared().getInbox().getMessages()) {
- JSONObject messageJson = new JSONObject();
- messageJson.putOpt("id", message.getMessageId());
- messageJson.putOpt("title", message.getTitle());
- messageJson.putOpt("sentDate", message.getSentDateMS());
- messageJson.putOpt("listIconUrl", message.getListIconUrl());
- messageJson.putOpt("isRead", message.isRead());
-
- JSONObject extrasJson = new JSONObject();
- Bundle extras = message.getExtras();
- for (String key : extras.keySet()) {
- Object value = extras.get(key);
- extrasJson.putOpt(key, value);
- }
-
- messageJson.put("extras", extrasJson);
-
- messagesJson.put(messageJson);
- }
-
- callbackContext.success(messagesJson);
- }
-
- /**
- * Displays an inbox message.
- *
- * @param data The call data. The message ID is expected to be the first entry.
- * @param callbackContext The callback context.
- * @throws JSONException
- */
- private void displayInboxMessage(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- final String messageId = data.getString(0);
- Message message = MessageCenter.shared().getInbox().getMessage(messageId);
-
- if (message == null) {
- callbackContext.error("Message not found: " + messageId);
- return;
- }
-
- cordova.getActivity().runOnUiThread(new Runnable() {
- @Override
- public void run() {
- Intent intent = new Intent(cordova.getActivity(), com.urbanairship.cordova.CustomMessageActivity.class)
- .setAction(MessageCenter.VIEW_MESSAGE_INTENT_ACTION)
- .setPackage(cordova.getActivity().getPackageName())
- .setData(Uri.fromParts(MessageCenter.MESSAGE_DATA_SCHEME, messageId, null))
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
-
- cordova.getActivity().startActivity(intent);
- }
- });
-
- callbackContext.success();
- }
-
- /**
- * Dismiss the inbox message.
- *
- * @param data The call data. The message ID is expected to be the first entry.
- * @param callbackContext The callback context.
- * @throws JSONException
- */
- private void dismissInboxMessage(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) {
- PluginLogger.debug("Dismissing Inbox Message");
- Intent intent = new Intent(cordova.getActivity(), com.urbanairship.cordova.CustomMessageActivity.class)
- .setAction(com.urbanairship.cordova.CustomMessageActivity.CLOSE_INTENT_ACTION)
- .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
-
- cordova.getActivity().startActivity(intent);
-
- callbackContext.success();
- }
-
- /**
- * Refreshes the inbox.
- *
- * @param data The call data. The message ID is expected to be the first entry.
- * @param callbackContext The callback context.
- */
- private void refreshInbox(@NonNull JSONArray data, @NonNull final CallbackContext callbackContext) {
- cordova.getActivity().runOnUiThread(new Runnable() {
- @Override
- public void run() {
- MessageCenter.shared().getInbox().fetchMessages(new Inbox.FetchMessagesCallback() {
- @Override
- public void onFinished(boolean success) {
- if (success) {
- callbackContext.success();
- } else {
- callbackContext.error("Inbox failed to refresh");
- }
- }
- });
- }
- });
- }
-
- /**
- * Checks if app notifications are enabled or not.
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- */
- private void isAppNotificationsEnabled(@NonNull JSONArray data, @NonNull final CallbackContext callbackContext) {
- int value = UAirship.shared().getPushManager().isOptIn() ? 1 : 0;
- callbackContext.success(value);
- }
-
- /**
- * Gets currently active notifications.
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- */
- private void getActiveNotifications(@NonNull JSONArray data, @NonNull final CallbackContext callbackContext) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- JSONArray notificationsJSON = new JSONArray();
-
- NotificationManager notificationManager = (NotificationManager) UAirship.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
- StatusBarNotification[] statusBarNotifications = notificationManager.getActiveNotifications();
-
- for (StatusBarNotification statusBarNotification : statusBarNotifications) {
- int id = statusBarNotification.getId();
- String tag = statusBarNotification.getTag();
- PushMessage pushMessage = com.urbanairship.cordova.Utils.messageFromNotification(statusBarNotification);
-
- try {
- notificationsJSON.put(com.urbanairship.cordova.Utils.notificationObject(pushMessage, tag, id));
- } catch (Exception e) {
- PluginLogger.error(e, "Unable to serialize push message: %s", pushMessage);
- }
- }
-
- callbackContext.success(notificationsJSON);
- } else {
- callbackContext.error("Getting active notifications is only supported on Marshmallow and newer devices.");
- }
- }
-
- /**
- * Clears all notifications.
- *
- * @param data The call data.
- * @param callbackContext The callback context
- * @throws JSONException
- */
- private void clearNotification(@NonNull JSONArray data, @NonNull final CallbackContext callbackContext) throws JSONException {
- final String identifier = data.getString(0);
-
- if (UAStringUtil.isEmpty(identifier)) {
- return;
- }
-
- String[] parts = identifier.split(":", 2);
-
- if (parts.length == 0) {
- callbackContext.error("Invalid identifier: " + identifier);
- return;
- }
-
- int id;
- String tag = null;
-
- try {
- id = Integer.parseInt(parts[0]);
- } catch (NumberFormatException e) {
- callbackContext.error("Invalid identifier: " + identifier);
- return;
- }
-
- if (parts.length == 2) {
- tag = parts[1];
- }
-
-
- NotificationManagerCompat.from(UAirship.getApplicationContext()).cancel(tag, id);
-
- callbackContext.success();
- }
-
- /**
- * Edits the channel attributes.
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- */
- private void editChannelAttributes(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- JSONArray operations = data.getJSONArray(0);
-
- PluginLogger.debug("Editing channel attributes: %s", operations);
-
- AttributeEditor editor = UAirship.shared().getChannel().editAttributes();
- applyAttributesOperations(editor, operations);
- editor.apply();
-
- callbackContext.success();
- }
-
- /**
- * Edits the named user attributes.
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- */
- private void editNamedUserAttributes(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- JSONArray operations = data.getJSONArray(0);
-
- PluginLogger.debug("Editing named user attributes: %s", operations);
-
- AttributeEditor editor = UAirship.shared().getContact().editAttributes();
- applyAttributesOperations(editor, operations);
- editor.apply();
-
- callbackContext.success();
- }
-
- /**
- * Helper method to apply attribute operations to an AttributeEditor.
- *
- * @param editor The attribute editor.
- * @param operations The attribute operations.
- */
- private static void applyAttributesOperations(AttributeEditor editor, JSONArray operations) throws JSONException {
- for (int i = 0; i < operations.length(); i++) {
- JSONObject operation = operations.optJSONObject(i);
- if (operation == null) {
- continue;
- }
-
- String action = operation.optString(ATTRIBUTE_OPERATION_TYPE);
- String key = operation.optString(ATTRIBUTE_OPERATION_KEY);
-
- if (ATTRIBUTE_OPERATION_SET.equals(action)) {
- Object value = operation.opt(ATTRIBUTE_OPERATION_VALUE);
- String valueType = (String) operation.opt(ATTRIBUTE_OPERATION_VALUETYPE);
- if ("string".equals(valueType)) {
- editor.setAttribute(key, (String) value);
- } else if ("number".equals(valueType)) {
- editor.setAttribute(key, ((Number) value).doubleValue());
- } else if ("date".equals(valueType)) {
- // JavaScript's date type doesn't pass through the JS to native bridge. Dates are instead serialized as milliseconds since epoch.
- editor.setAttribute(key, new Date(((Number) value).longValue()));
- } else {
- PluginLogger.warn("Unknown channel attribute type: %s", valueType);
- }
- } else if (ATTRIBUTE_OPERATION_REMOVE.equals(action)) {
- editor.removeAttribute(key);
- }
- }
- }
-
- /**
- * Initiates screen tracking for a specific app screen.
- *
- * Expected arguments: String
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- */
- private void trackScreen(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- String screen = data.getString(0);
- UAirship.shared().getAnalytics().trackScreen(screen);
- callbackContext.success();
- }
-
- /**
- * Enables features, adding them to the set of currently enabled features.
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- * @throws JSONException
- */
- private void enableFeature(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- JSONArray features = data.getJSONArray(0);
- if (isValidFeature(features)) {
- UAirship.shared().getPrivacyManager().enable(stringToFeature(features));
- callbackContext.success();
- } else {
- callbackContext.error("Invalid features " + features);
- }
- }
-
- /**
- * Disables features, removing them from the set of currently enabled features.
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- * @throws JSONException
- */
- private void disableFeature(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- JSONArray features = data.getJSONArray(0);
- if (isValidFeature(features)) {
- UAirship.shared().getPrivacyManager().disable(stringToFeature(features));
- callbackContext.success();
- } else {
- callbackContext.error("Invalid features " + features);
- }
- }
-
- /**
- * Sets the current enabled features, replacing any currently enabled features with the given set.
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- * @throws JSONException
- */
- private void setEnabledFeatures(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- JSONArray features = data.getJSONArray(0);
- if (isValidFeature(features)) {
- UAirship.shared().getPrivacyManager().setEnabledFeatures(stringToFeature(features));
- callbackContext.success();
- } else {
- callbackContext.error("Invalid features " + features);
- }
- }
-
- /**
- * Gets the current enabled features.
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- */
- private void getEnabledFeatures(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) {
- callbackContext.success(featureToString(UAirship.shared().getPrivacyManager().getEnabledFeatures()));
- }
-
- /**
- * Checks if all of the given features are enabled.
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- */
- private void isFeatureEnabled(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- JSONArray features = data.getJSONArray(0);
- if (isValidFeature(features)) {
- int value = UAirship.shared().getPrivacyManager().isEnabled(stringToFeature(features)) ? 1 : 0;
- callbackContext.success(value);
- } else {
- callbackContext.error("Invalid features " + features);
- }
- }
-
- /**
- * Opens the Preference Center with the given preferenceCenterId.
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- * @throws JSONException
- */
- private void openPreferenceCenter(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- String preferenceCenterId = data.getString(0);
- PreferenceCenter.shared().open(preferenceCenterId);
- callbackContext.success();
- }
-
- /**
- * Gets the configuration of the Preference Center with the given Id trough a callback method.
- *
- * @param data The call data.
- * @param callbackContext The callback context.
- */
- private void getPreferenceCenterConfig(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- String preferenceCenterId = data.getString(0);
- PreferenceCenter.shared().getJsonConfig(preferenceCenterId).addResultCallback(result -> {
- if (result == null) {
- callbackContext.success();
- return;
- }
-
- try {
- callbackContext.success(new JSONObject(result.toString()));
- } catch (JSONException e) {
- callbackContext.error(e.getMessage());
- }
- });
- }
-
- /**
- * Set to true the override the preference center.
- *
- * @param callbackContext The callback context.
- * @throws JSONException
- */
- private void setUseCustomPreferenceCenterUi(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- String preferenceCenterId = data.getString(0);
- boolean useCustomUi = data.getBoolean(1);
- pluginManager.editConfig()
- .setUseCustomPreferenceCenterUi(preferenceCenterId, useCustomUi)
- .apply();
- callbackContext.success();
- }
-
- private void setForegroundNotificationsEnabled(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- boolean enabled = data.getBoolean(0);
- pluginManager.editConfig()
- .setForegroundNotificationsEnabled(enabled)
- .apply();
- callbackContext.success();
- }
-
- /**
- * Overriding the locale.
- *
- * @param data The call data.
- * @throws JSONException
- */
- private void setCurrentLocale(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- String localeIdentifier = data.getString(0);
- UAirship.shared().setLocaleOverride(new Locale(localeIdentifier));
- callbackContext.success();
- }
-
- /**
- * Getting the locale currently used by Airship.
- * @param callbackContext The callback context.
- * @throws JSONException
- */
-
- private void getCurrentLocale(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- Locale airshipLocale = UAirship.shared().getLocale();
- callbackContext.success(airshipLocale.getLanguage());
- }
-
- /**
- * Resets the current locale.
- * @param callbackContext The callback context.
- * @throws JSONException
- */
- private void clearLocale(@NonNull JSONArray data, @NonNull CallbackContext callbackContext) throws JSONException {
- UAirship.shared().setLocaleOverride(null);
- callbackContext.success();
- }
-
- /**
- * Helper method to verify if a Feature is authorized.
- *
- * @param features The String features to verify.
- * @return {@code true} if the provided features are authorized, otherwise {@code false}.
- */
- private boolean isValidFeature(JSONArray features) throws JSONException {
- if (features == null || features.length() == 0) {
- return false;
- }
-
- for (int i = 0; i < features.length(); i++) {
- if (!AUTHORIZED_FEATURES.containsKey(features.getString(i))) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Helper method to parse a String features JSONArray into {@link PrivacyManager.Feature} int array.
- *
- * @param features The String features JSONArray to parse.
- * @return The {@link PrivacyManager.Feature} int array.
- */
- @PrivacyManager.Feature
- private @NonNull
- int[] stringToFeature(@NonNull JSONArray features) throws JSONException {
- @PrivacyManager.Feature
- int[] intFeatures = new int[features.length()];
-
- for (int i = 0; i < features.length(); i++) {
- intFeatures[i] = (int) AUTHORIZED_FEATURES.get(features.getString(i));
- }
- return intFeatures;
- }
-
- /**
- * Helper method to parse a {@link PrivacyManager.Feature} int array into a String features JSONArray.
- *
- * @param features The {@link PrivacyManager.Feature} int array to parse.
- * @return The String feature JSONArray.
- */
- private @NonNull
- JSONArray featureToString(@PrivacyManager.Feature int features) {
- List stringFeatures = new ArrayList();
-
- if (features == PrivacyManager.FEATURE_ALL) {
- stringFeatures.add("FEATURE_ALL");
- } else if (features == PrivacyManager.FEATURE_NONE) {
- stringFeatures.add("FEATURE_NONE");
- } else {
- for (String feature : AUTHORIZED_FEATURES.keySet()) {
- @PrivacyManager.Feature
- int intFeature = (int) AUTHORIZED_FEATURES.get(feature);
- if (((intFeature & features) != 0) && (intFeature != PrivacyManager.FEATURE_ALL)) {
- stringFeatures.add(feature);
- }
- }
- }
- return new JSONArray(stringFeatures);
- }
-
-}
diff --git a/urbanairship-cordova/src/android/Utils.java b/urbanairship-cordova/src/android/Utils.java
deleted file mode 100644
index 0903ed5b..00000000
--- a/urbanairship-cordova/src/android/Utils.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-package com.urbanairship.cordova;
-
-import android.os.Bundle;
-import android.os.Message;
-import android.service.notification.StatusBarNotification;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.urbanairship.push.PushMessage;
-import com.urbanairship.util.UAStringUtil;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Utility methods.
- */
-public class Utils {
-
- /**
- * Parses a {@link PushMessage} from a status bar notification.
- *
- * @param statusBarNotification The status bar notification.
- * @return The push message from the status bar notification.
- */
- @NonNull
- public static PushMessage messageFromNotification(@NonNull StatusBarNotification statusBarNotification) {
- Bundle extras = statusBarNotification.getNotification().extras;
- if (extras == null) {
- return new PushMessage(new Bundle());
- }
-
- Bundle pushBundle = extras.getBundle(CordovaNotificationProvider.PUSH_MESSAGE_BUNDLE_EXTRA);
- if (pushBundle == null) {
- return new PushMessage(new Bundle());
- } else {
- return new PushMessage(pushBundle);
- }
- }
-
- /**
- * Helper method to create a notification JSONObject.
- *
- * @param message The push message.
- * @param notificationTag The optional notification tag.
- * @param notificationId The optional notification ID.
- * @return A JSONObject containing the notification data.
- */
- @NonNull
- public static JSONObject notificationObject(@NonNull PushMessage message, @Nullable String notificationTag, @Nullable Integer notificationId) throws JSONException {
- JSONObject data = new JSONObject();
- Map extras = new HashMap();
- for (String key : message.getPushBundle().keySet()) {
- if ("android.support.content.wakelockid".equals(key)) {
- continue;
- }
- if ("google.sent_time".equals(key)) {
- extras.put(key, Long.toString(message.getPushBundle().getLong(key)));
- continue;
- }
- if ("google.ttl".equals(key)) {
- extras.put(key, Integer.toString(message.getPushBundle().getInt(key)));
- continue;
- }
- String value = message.getPushBundle().getString(key);
- if (value != null) {
- extras.put(key, value);
- }
- }
-
- data.putOpt("message", message.getAlert());
- data.putOpt("title", message.getTitle());
- data.putOpt("subtitle", message.getSummary());
- data.putOpt("extras", new JSONObject(extras));
-
- String actions = message.getExtra(PushMessage.EXTRA_ACTIONS);
- if (actions != null) {
- data.putOpt("actions", new JSONObject(actions));
- }
-
- if (notificationId != null) {
- data.putOpt("notification_id", notificationId);
- data.putOpt("notificationId", getNotificationId(notificationId, notificationTag));
- }
- return data;
- }
-
- @NonNull
- private static String getNotificationId(int notificationId, @Nullable String notificationTag) {
- String id = String.valueOf(notificationId);
- if (!UAStringUtil.isEmpty(notificationTag)) {
- id += ":" + notificationTag;
- }
- return id;
- }
-}
diff --git a/urbanairship-cordova/src/android/build-extras.gradle b/urbanairship-cordova/src/android/build-extras.gradle
deleted file mode 100644
index fa447b75..00000000
--- a/urbanairship-cordova/src/android/build-extras.gradle
+++ /dev/null
@@ -1,18 +0,0 @@
-dependencies {
- def airshipVersion = "16.11.1"
- implementation "com.urbanairship.android:urbanairship-fcm:$airshipVersion"
- implementation "com.urbanairship.android:urbanairship-message-center:$airshipVersion"
- implementation "com.urbanairship.android:urbanairship-automation:$airshipVersion"
- implementation "com.urbanairship.android:urbanairship-preference-center:$airshipVersion"
-}
-
-cdvPluginPostBuildExtras.push({
- android {
- compileSdkVersion 33
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- }
-})
diff --git a/urbanairship-cordova/src/android/events/DeepLinkEvent.java b/urbanairship-cordova/src/android/events/DeepLinkEvent.java
deleted file mode 100644
index c4e649a1..00000000
--- a/urbanairship-cordova/src/android/events/DeepLinkEvent.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-package com.urbanairship.cordova.events;
-
-import com.urbanairship.cordova.PluginLogger;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * Deep link event when a new deep link is received.
- */
-public class DeepLinkEvent implements Event {
- private static final String EVENT_DEEPLINK_ACTION = "urbanairship.deep_link";
-
- private final String deepLink;
-
- public DeepLinkEvent(String deepLink) {
- this.deepLink = deepLink;
- }
-
- public String getDeepLink() {
- return deepLink;
- }
-
- @Override
- public String getEventName() {
- return EVENT_DEEPLINK_ACTION;
- }
-
- @Override
- public JSONObject getEventData() {
- JSONObject jsonObject = new JSONObject();
- try {
- jsonObject.putOpt("deepLink", deepLink);
- } catch (JSONException e) {
- PluginLogger.error(e, "Error constructing deep link event");
- }
- return jsonObject;
- }
-}
diff --git a/urbanairship-cordova/src/android/events/Event.java b/urbanairship-cordova/src/android/events/Event.java
deleted file mode 100644
index 7b657df5..00000000
--- a/urbanairship-cordova/src/android/events/Event.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-package com.urbanairship.cordova.events;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import org.json.JSONObject;
-
-/**
- * Interface for Urban Airship Cordova events.
- */
-public interface Event {
-
- /**
- * The event name.
- *
- * @return The event name.
- */
- @NonNull
- String getEventName();
-
- /**
- * The event data.
- *
- * @return The event data.
- */
- @Nullable
- JSONObject getEventData();
-}
diff --git a/urbanairship-cordova/src/android/events/InboxEvent.java b/urbanairship-cordova/src/android/events/InboxEvent.java
deleted file mode 100644
index 3114ef08..00000000
--- a/urbanairship-cordova/src/android/events/InboxEvent.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-package com.urbanairship.cordova.events;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import org.json.JSONObject;
-
-/**
- * Inbox update event.
- */
-public class InboxEvent implements Event {
- private static final String EVENT_INBOX_UPDATED = "urbanairship.inbox_updated";
-
- @Override
- @NonNull
- public String getEventName() {
- return EVENT_INBOX_UPDATED;
- }
-
- @Override
- @Nullable
- public JSONObject getEventData() {
- return null;
- }
-}
diff --git a/urbanairship-cordova/src/android/events/NotificationOpenedEvent.java b/urbanairship-cordova/src/android/events/NotificationOpenedEvent.java
deleted file mode 100644
index 22ae221c..00000000
--- a/urbanairship-cordova/src/android/events/NotificationOpenedEvent.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-package com.urbanairship.cordova.events;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.urbanairship.cordova.PluginLogger;
-import com.urbanairship.push.NotificationActionButtonInfo;
-import com.urbanairship.push.NotificationInfo;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * Notification opened event.
- */
-public class NotificationOpenedEvent extends PushEvent {
-
- private static final String EVENT_NOTIFICATION_OPENED = "urbanairship.notification_opened";
-
- private static final String ACTION_ID = "actionID";
- private static final String IS_FOREGROUND = "isForeground";
-
- private final NotificationActionButtonInfo actionButtonInfo;
-
-
- /**
- * Creates an event for a notification response.
- *
- * @param notificationInfo The notification info.
- */
- public NotificationOpenedEvent(@NonNull NotificationInfo notificationInfo) {
- this(notificationInfo, null);
- }
-
- /**
- * Creates an event for a notification action button response.
- *
- * @param notificationInfo The notification info.
- * @param actionButtonInfo The notification action button info.
- */
- public NotificationOpenedEvent(@NonNull NotificationInfo notificationInfo, @Nullable NotificationActionButtonInfo actionButtonInfo) {
- super(notificationInfo.getNotificationId(), notificationInfo.getMessage());
- this.actionButtonInfo = actionButtonInfo;
- }
-
- @Override
- @NonNull
- public String getEventName() {
- return EVENT_NOTIFICATION_OPENED;
- }
-
-
- @Override
- @Nullable
- public JSONObject getEventData() {
- JSONObject jsonObject = super.getEventData();
-
- if (jsonObject == null) {
- return null;
- }
-
- try {
- if (actionButtonInfo != null) {
- jsonObject.put(ACTION_ID, actionButtonInfo.getButtonId());
- jsonObject.put(IS_FOREGROUND, actionButtonInfo.isForeground());
- } else {
- jsonObject.put(IS_FOREGROUND, true);
- }
- } catch (JSONException e) {
- PluginLogger.error(e,"Error constructing notification object");
- }
-
- return jsonObject;
- }
-}
diff --git a/urbanairship-cordova/src/android/events/NotificationOptInEvent.java b/urbanairship-cordova/src/android/events/NotificationOptInEvent.java
deleted file mode 100644
index b4c4799e..00000000
--- a/urbanairship-cordova/src/android/events/NotificationOptInEvent.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-package com.urbanairship.cordova.events;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.urbanairship.cordova.PluginLogger;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-
-/**
- * Notification opt-in status event.
- */
-public class NotificationOptInEvent implements Event {
-
- private static final String NOTIFICATION_OPT_IN_STATUS_EVENT = "urbanairship.notification_opt_in_status";
- private static final String OPT_IN = "optIn";
-
- private final boolean optIn;
-
- /**
- * Default constructor.
- *
- * @param optIn The app opt-in status.
- */
- public NotificationOptInEvent(boolean optIn) {
- this.optIn = optIn;
- }
-
- @NonNull
- @Override
- public String getEventName() {
- return NOTIFICATION_OPT_IN_STATUS_EVENT;
- }
-
- @Override
- @Nullable
- public JSONObject getEventData() {
- JSONObject data = new JSONObject();
-
- try {
- data.put(OPT_IN, optIn);
- } catch (JSONException e) {
- PluginLogger.error(e, "Error adding opt-in event data");
- }
-
- return data;
- }
-}
diff --git a/urbanairship-cordova/src/android/events/PreferenceCenterEvent.java b/urbanairship-cordova/src/android/events/PreferenceCenterEvent.java
deleted file mode 100644
index 79f3f695..00000000
--- a/urbanairship-cordova/src/android/events/PreferenceCenterEvent.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-package com.urbanairship.cordova.events;
-
-import com.urbanairship.cordova.PluginLogger;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * Preference Center event when the open preference center listener is called.
- */
-public class PreferenceCenterEvent implements com.urbanairship.cordova.events.Event {
- private static final String EVENT_PREFERENCE_CENTER_ACTION = "urbanairship.open_preference_center";
-
- private final String preferenceCenterId;
-
- public PreferenceCenterEvent(String preferenceCenterId) {
- this.preferenceCenterId = preferenceCenterId;
- }
-
- public String getPreferenceCenterId() {
- return preferenceCenterId;
- }
-
- @Override
- public String getEventName() {
- return EVENT_PREFERENCE_CENTER_ACTION;
- }
-
- @Override
- public JSONObject getEventData() {
- JSONObject jsonObject = new JSONObject();
- try {
- jsonObject.putOpt("preferenceCenterId", preferenceCenterId);
- } catch (JSONException e) {
- PluginLogger.error(e, "Error constructing preference center event");
- }
- return jsonObject;
- }
-}
diff --git a/urbanairship-cordova/src/android/events/PushEvent.java b/urbanairship-cordova/src/android/events/PushEvent.java
deleted file mode 100644
index ce03b11a..00000000
--- a/urbanairship-cordova/src/android/events/PushEvent.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-package com.urbanairship.cordova.events;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.urbanairship.cordova.PluginLogger;
-import com.urbanairship.cordova.Utils;
-import com.urbanairship.push.PushMessage;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * Push event.
- */
-public class PushEvent implements Event {
-
- private static final String EVENT_PUSH_RECEIVED = "urbanairship.push";
-
- private final PushMessage message;
- private final Integer notificationId;
-
- public PushEvent(@Nullable Integer notificationId, @NonNull PushMessage message) {
- this.notificationId = notificationId;
- this.message = message;
- }
-
- @NonNull
- @Override
- public String getEventName() {
- return EVENT_PUSH_RECEIVED;
- }
-
- @Nullable
- @Override
- public JSONObject getEventData() {
- try {
- return Utils.notificationObject(message, message.getNotificationTag(), notificationId);
- } catch (JSONException e) {
- PluginLogger.error(e, "Error constructing notification object");
- return null;
- }
- }
-}
diff --git a/urbanairship-cordova/src/android/events/RegistrationEvent.java b/urbanairship-cordova/src/android/events/RegistrationEvent.java
deleted file mode 100644
index 61900dc6..00000000
--- a/urbanairship-cordova/src/android/events/RegistrationEvent.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-package com.urbanairship.cordova.events;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.urbanairship.cordova.PluginLogger;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-/**
- * Registration event.
- */
-public class RegistrationEvent implements Event {
-
- private static final String EVENT_CHANNEL_UPDATED = "urbanairship.registration";
-
- private static final String CHANNEL_ID = "channelID";
- private static final String REGISTRATION_TOKEN = "registrationToken";
-
- private final String channel;
- private final String registrationToken;
- private final boolean success;
-
-
- public RegistrationEvent(@Nullable String channel, @Nullable String registrationToken, boolean success) {
- this.channel = channel;
- this.registrationToken = registrationToken;
- this.success = success;
- }
-
- @NonNull
- @Override
- public String getEventName() {
- return EVENT_CHANNEL_UPDATED;
- }
-
- @Nullable
- @Override
- public JSONObject getEventData() {
- JSONObject data = new JSONObject();
- try {
- if (success) {
- data.put(CHANNEL_ID, channel);
- if (registrationToken != null) {
- data.put(REGISTRATION_TOKEN, registrationToken);
- }
-
- } else {
- data.put("error", "Invalid registration.");
- }
- } catch (JSONException e) {
- PluginLogger.error(e, "Error in channel registration");
- }
-
- return data;
- }
-}
diff --git a/urbanairship-cordova/src/android/events/ShowInboxEvent.java b/urbanairship-cordova/src/android/events/ShowInboxEvent.java
deleted file mode 100644
index 07672d90..00000000
--- a/urbanairship-cordova/src/android/events/ShowInboxEvent.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-package com.urbanairship.cordova.events;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.urbanairship.cordova.PluginLogger;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-
-/**
- * Show inbox event.
- */
-public class ShowInboxEvent implements Event {
-
- private static final String SHOW_INBOX_EVENT = "urbanairship.show_inbox";
- private static final String MESSAGE_ID = "messageId";
-
- private final String messageId;
-
- /**
- * Default constructor.
- *
- * @param messageId The optional message ID.
- */
- public ShowInboxEvent(@Nullable String messageId) {
- this.messageId = messageId;
- }
-
- @Override
- @NonNull
- public String getEventName() {
- return SHOW_INBOX_EVENT;
- }
-
- @Override
- @Nullable
- public JSONObject getEventData() {
- JSONObject data = new JSONObject();
-
- try {
- if (messageId != null) {
- data.put(MESSAGE_ID, messageId);
- }
- } catch (JSONException e) {
- PluginLogger.error(e, "Error in show inbox event");
- }
-
- return data;
- }
-}
diff --git a/urbanairship-cordova/src/ios/UACordovaPluginManager.h b/urbanairship-cordova/src/ios/UACordovaPluginManager.h
deleted file mode 100644
index b5b8952e..00000000
--- a/urbanairship-cordova/src/ios/UACordovaPluginManager.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import
-
-#if __has_include("AirshipLib.h")
-#import "AirshipLib.h"
-#else
-@import AirshipKit;
-#endif
-
-NS_ASSUME_NONNULL_BEGIN
-
-/**
- * Manager delegate.
- */
-@protocol UACordovaPluginManagerDelegate
-
-/**
- * Called to notify listeners of a new or pending event.
- *
- * @param eventType The event type string.
- * @param data The json payload dictionary.
- *
- * @return `YES` if a listener was notified, `NO` otherwise.
- */
--(BOOL)notifyListener:(NSString *)eventType data:(NSDictionary *)data;
-@end
-
-/**
- * Manages config and event forwarding from the Urban Airship SDK.
- */
-@interface UACordovaPluginManager : NSObject
-
-/**
- * Delegate.
- */
-@property (nonatomic, weak, nullable) id delegate;
-
-/**
- * Last received deep link.
- */
-@property (nonatomic, copy, nullable) NSString *lastReceivedDeepLink;
-
-/**
- * Flag that enables/disables auto launching the default message center.
- */
-@property (nonatomic, assign) BOOL autoLaunchMessageCenter;
-
-/**
- * Last received notification response.
- */
-@property (nonatomic, copy, nullable) NSDictionary *lastReceivedNotificationResponse;
-
-/**
- * Checks if Airship is ready.
- */
-@property (nonatomic, readonly, assign) BOOL isAirshipReady;
-
-/**
- * Factory method.
- * @param defaultConfig The default cordova config.
- * @return Plugin Manager instance.
- */
-+ (instancetype)pluginManagerWithDefaultConfig:(NSDictionary *)defaultConfig;
-
-/**
- * Attempts takeOff if Airship is not already flying.
- */
-- (void)attemptTakeOff;
-
-/**
- * Attempts takeOff if Airship is not already flying with launch options.
- */
-- (void)attemptTakeOffWithLaunchOptions:(nullable NSDictionary *)launchOptions;
-
-/**
- * Sets the development credentials.
- * @param appKey UA app key.
- * @param appSecret UA app secret.
- */
-- (void)setDevelopmentAppKey:(NSString *)appKey appSecret:(NSString *)appSecret;
-
-/**
- * Sets the production credentials.
- * @param appKey The appKey.
- * @param appSecret The appSecret.
- */
-- (void)setProductionAppKey:(NSString *)appKey appSecret:(NSString *)appSecret;
-
-/**
- * Sets the cloud site.
- * @param site The site, either "US" or "EU".
- */
-- (void)setCloudSite:(NSString *)site;
-
-/**
- * Sets the message center style config file.
- * @param fileName The plist file name that will be used to set the message center style.
- */
-- (void)setMessageCenterStyleFile:(NSString *)fileName;
-
-/**
- * Sets the presentation options.
- * @param options The presentation options.
- */
-- (void)setPresentationOptions:(NSUInteger)options;
-
-- (void)setPreferenceCenter:(NSString *)preferenceCenterID useCustomUI:(BOOL)useCustomUI;
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/urbanairship-cordova/src/ios/UACordovaPluginManager.m b/urbanairship-cordova/src/ios/UACordovaPluginManager.m
deleted file mode 100644
index 615842c5..00000000
--- a/urbanairship-cordova/src/ios/UACordovaPluginManager.m
+++ /dev/null
@@ -1,436 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaPluginManager.h"
-
-#if __has_include("AirshipLib.h")
-#import "AirshipLib.h"
-#import "AirshipMessageCenterLib.h"
-#else
-@import AirshipKit;
-#endif
-
-#import "UACordovaEvent.h"
-#import "UACordovaDeepLinkEvent.h"
-#import "UACordovaInboxUpdatedEvent.h"
-#import "UACordovaNotificationOpenedEvent.h"
-#import "UACordovaNotificationOptInEvent.h"
-#import "UACordovaPushEvent.h"
-#import "UACordovaRegistrationEvent.h"
-#import "UACordovaShowInboxEvent.h"
-#import "UACordovaPreferenceCenterEvent.h"
-
-// Config keys
-NSString *const ProductionAppKeyConfigKey = @"com.urbanairship.production_app_key";
-NSString *const ProductionAppSecretConfigKey = @"com.urbanairship.production_app_secret";
-NSString *const DevelopmentAppKeyConfigKey = @"com.urbanairship.development_app_key";
-NSString *const DevelopmentAppSecretConfigKey = @"com.urbanairship.development_app_secret";
-NSString *const ProductionLogLevelKey = @"com.urbanairship.production_log_level";
-NSString *const DevelopmentLogLevelKey = @"com.urbanairship.development_log_level";
-NSString *const ProductionConfigKey = @"com.urbanairship.in_production";
-NSString *const EnablePushOnLaunchConfigKey = @"com.urbanairship.enable_push_onlaunch";
-NSString *const ClearBadgeOnLaunchConfigKey = @"com.urbanairship.clear_badge_onlaunch";
-NSString *const EnableAnalyticsConfigKey = @"com.urbanairship.enable_analytics";
-NSString *const AutoLaunchMessageCenterKey = @"com.urbanairship.auto_launch_message_center";
-NSString *const NotificationPresentationAlertKey = @"com.urbanairship.ios_foreground_notification_presentation_alert";
-NSString *const NotificationPresentationBadgeKey = @"com.urbanairship.ios_foreground_notification_presentation_badge";
-NSString *const NotificationPresentationSoundKey = @"com.urbanairship.ios_foreground_notification_presentation_sound";
-NSString *const CloudSiteConfigKey = @"com.urbanairship.site";
-NSString *const MessageCenterStyleConfigKey = @"com.urbanairship.message.center.style.file";
-NSString *const CloudSiteEUString = @"EU";
-NSString *const InitialConfigURLKey = @"com.urbanairship.initial_config_url";
-
-NSString *const UACordovaPluginVersionKey = @"UACordovaPluginVersion";
-
-// Events
-NSString *const CategoriesPlistPath = @"UACustomNotificationCategories";
-
-
-@interface UACordovaPluginManager()
-@property (nonatomic, strong) NSDictionary *defaultConfig;
-@property (nonatomic, strong) NSMutableArray *> *pendingEvents;
-@property (nonatomic, assign) BOOL isAirshipReady;
-
-@end
-@implementation UACordovaPluginManager
-
-- (void)load {
- [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidFinishLaunchingNotification
- object:nil
- queue:nil usingBlock:^(NSNotification * _Nonnull note) {
-
- [self attemptTakeOffWithLaunchOptions:note.userInfo];
- }];
-}
-
-- (void)dealloc {
- [UAirship push].pushNotificationDelegate = nil;
- [UAirship push].registrationDelegate = nil;
- [UAMessageCenter shared].displayDelegate = nil;
- [UAPreferenceCenter shared].openDelegate = nil;
- [[NSNotificationCenter defaultCenter] removeObserver:self];
-}
-
-- (instancetype)initWithDefaultConfig:(NSDictionary *)defaultConfig {
- self = [super init];
-
- if (self) {
- self.defaultConfig = defaultConfig;
- self.pendingEvents = [NSMutableArray array];
- }
-
- return self;
-}
-
-+ (instancetype)pluginManagerWithDefaultConfig:(NSDictionary *)defaultConfig {
- return [[UACordovaPluginManager alloc] initWithDefaultConfig:defaultConfig];
-}
-
-- (void)attemptTakeOff {
- [self attemptTakeOffWithLaunchOptions:nil];
-}
-
-- (void)attemptTakeOffWithLaunchOptions:(NSDictionary *)launchOptions {
- if (self.isAirshipReady) {
- return;
- }
-
- UAConfig *config = [self createAirshipConfig];
- if (![config validate]) {
- return;
- }
-
- [UAirship takeOff:config launchOptions:launchOptions];
- [self registerCordovaPluginVersion];
-
- if ([[self configValueForKey:EnablePushOnLaunchConfigKey] boolValue]) {
- [UAirship push].userPushNotificationsEnabled = true;
- }
-
- if ([[self configValueForKey:ClearBadgeOnLaunchConfigKey] boolValue]) {
- [[UAirship push] resetBadge];
- }
-
- [self loadCustomNotificationCategories];
-
- [UAirship push].pushNotificationDelegate = self;
- [UAirship push].registrationDelegate = self;
- [UAMessageCenter shared].displayDelegate = self;
- [UAirship shared].deepLinkDelegate = self;
- [UAPreferenceCenter shared].openDelegate = self;
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(inboxUpdated)
- name:UAInboxMessageListUpdatedNotification
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(channelRegistrationSucceeded:)
- name:UAChannel.channelUpdatedEvent
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(channelRegistrationFailed)
- name:UAChannel.channelRegistrationFailedEvent
- object:nil];
-
-
-
- self.isAirshipReady = YES;
-}
-
-- (void)loadCustomNotificationCategories {
- NSString *categoriesPath = [[NSBundle mainBundle] pathForResource:CategoriesPlistPath ofType:@"plist"];
- NSSet *customNotificationCategories = [UANotificationCategories createCategoriesFromFile:categoriesPath];
-
- if (customNotificationCategories.count) {
- UA_LDEBUG(@"Registering custom notification categories: %@", customNotificationCategories);
- [UAirship push].customCategories = customNotificationCategories;
- [[UAirship push] updateRegistration];
- }
-}
-
-- (UAConfig *)createAirshipConfig {
- UAConfig *airshipConfig = [UAConfig config];
- airshipConfig.productionAppKey = [self configValueForKey:ProductionAppKeyConfigKey];
- airshipConfig.productionAppSecret = [self configValueForKey:ProductionAppSecretConfigKey];
- airshipConfig.developmentAppKey = [self configValueForKey:DevelopmentAppKeyConfigKey];
- airshipConfig.developmentAppSecret = [self configValueForKey:DevelopmentAppSecretConfigKey];
- airshipConfig.URLAllowListScopeOpenURL = @[@"*"];
-
- NSString *cloudSite = [self configValueForKey:CloudSiteConfigKey];
- airshipConfig.site = [UACordovaPluginManager parseCloudSiteString:cloudSite];
-
- NSString* fileName = [self configValueForKey:MessageCenterStyleConfigKey];
- if (fileName == nil) {
- fileName = @"messageCenterConfigStyle";
- }
- airshipConfig.messageCenterStyleConfig = fileName;
-
- if ([self configValueForKey:ProductionConfigKey] != nil) {
- airshipConfig.inProduction = [[self configValueForKey:ProductionConfigKey] boolValue];
- }
-
- airshipConfig.developmentLogLevel = [self parseLogLevel:[self configValueForKey:DevelopmentLogLevelKey]
- defaultLogLevel:UALogLevelDebug];
-
- airshipConfig.productionLogLevel = [self parseLogLevel:[self configValueForKey:ProductionLogLevelKey]
- defaultLogLevel:UALogLevelError];
-
- if ([self configValueForKey:EnableAnalyticsConfigKey] != nil) {
- airshipConfig.isAnalyticsEnabled = [[self configValueForKey:EnableAnalyticsConfigKey] boolValue];
- }
-
- if ([self configValueForKey:InitialConfigURLKey] != nil) {
- airshipConfig.initialConfigURL = [self configValueForKey:InitialConfigURLKey];
- }
-
- airshipConfig.enabledFeatures = UAFeaturesAll;
-
- return airshipConfig;
-}
-
-- (void)registerCordovaPluginVersion {
- NSString *version = [NSBundle mainBundle].infoDictionary[UACordovaPluginVersionKey] ?: @"0.0.0";
- [[UAirship analytics] registerSDKExtension:UASDKExtensionCordova version:version];
-}
-
-- (id)configValueForKey:(NSString *)key {
- id value = [[NSUserDefaults standardUserDefaults] objectForKey:key];
- if (value != nil) {
- return value;
- }
-
- return self.defaultConfig[key];
-}
-
-- (BOOL)autoLaunchMessageCenter {
- if ([self configValueForKey:AutoLaunchMessageCenterKey] == nil) {
- return YES;
- }
-
- return [[self configValueForKey:AutoLaunchMessageCenterKey] boolValue];
-}
-
-- (void)setAutoLaunchMessageCenter:(BOOL)autoLaunchMessageCenter {
- [[NSUserDefaults standardUserDefaults] setValue:@(autoLaunchMessageCenter) forKey:AutoLaunchMessageCenterKey];
-}
-
-- (void)setProductionAppKey:(NSString *)appKey appSecret:(NSString *)appSecret {
- [[NSUserDefaults standardUserDefaults] setValue:appKey forKey:ProductionAppKeyConfigKey];
- [[NSUserDefaults standardUserDefaults] setValue:appSecret forKey:ProductionAppSecretConfigKey];
-}
-
-- (void)setDevelopmentAppKey:(NSString *)appKey appSecret:(NSString *)appSecret {
- [[NSUserDefaults standardUserDefaults] setValue:appKey forKey:DevelopmentAppKeyConfigKey];
- [[NSUserDefaults standardUserDefaults] setValue:appSecret forKey:DevelopmentAppSecretConfigKey];
-}
-
-- (void)setCloudSite:(NSString *)site {
- [[NSUserDefaults standardUserDefaults] setValue:site forKey:CloudSiteConfigKey];
-}
-
-- (void)setMessageCenterStyleFile:(NSString *)fileName {
- [[NSUserDefaults standardUserDefaults] setValue:fileName forKey:MessageCenterStyleConfigKey];
-}
-
-- (void)setPresentationOptions:(NSUInteger)options {
- [[NSUserDefaults standardUserDefaults] setValue:@(options & UNNotificationPresentationOptionAlert) forKey:NotificationPresentationAlertKey];
- [[NSUserDefaults standardUserDefaults] setValue:@(options & UNNotificationPresentationOptionBadge) forKey:NotificationPresentationBadgeKey];
- [[NSUserDefaults standardUserDefaults] setValue:@(options & UNNotificationPresentationOptionSound) forKey:NotificationPresentationSoundKey];
-}
-
--(NSInteger)parseLogLevel:(id)logLevel defaultLogLevel:(UALogLevel)defaultValue {
- if (![logLevel isKindOfClass:[NSString class]] || ![logLevel length]) {
- return defaultValue;
- }
-
- NSString *normalizedLogLevel = [[logLevel stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] lowercaseString];
-
- if ([normalizedLogLevel isEqualToString:@"verbose"]) {
- return UALogLevelTrace;
- } else if ([normalizedLogLevel isEqualToString:@"debug"]) {
- return UALogLevelDebug;
- } else if ([normalizedLogLevel isEqualToString:@"info"]) {
- return UALogLevelInfo;
- } else if ([normalizedLogLevel isEqualToString:@"warning"]) {
- return UALogLevelWarn;
- } else if ([normalizedLogLevel isEqualToString:@"error"]) {
- return UALogLevelError;
- } else if ([normalizedLogLevel isEqualToString:@"none"]) {
- return UALogLevelNone;
- }
-
- return defaultValue;
-}
-
-+ (UACloudSite)parseCloudSiteString:(NSString *)site {
- if ([CloudSiteEUString caseInsensitiveCompare:site] == NSOrderedSame) {
- return UACloudSiteEU;
- } else {
- return UACloudSiteUS;
- }
-}
-
-#pragma mark -
-#pragma mark UAInboxDelegate
-
-- (void)displayMessageCenterForMessageID:(NSString *)messageID animated:(BOOL)animated {
- if (self.autoLaunchMessageCenter) {
- [[UAMessageCenter shared].defaultUI displayMessageCenterForMessageID:messageID animated:true];
- } else {
- [self fireEvent:[UACordovaShowInboxEvent eventWithMessageID:messageID]];
- }
-}
-
-- (void)displayMessageCenterAnimated:(BOOL)animated {
- if (self.autoLaunchMessageCenter) {
- [[UAMessageCenter shared].defaultUI displayMessageCenterAnimated:animated];
- } else {
- [self fireEvent:[UACordovaShowInboxEvent event]];
- }
-}
-
-- (void)dismissMessageCenterAnimated:(BOOL)animated {
- if (self.autoLaunchMessageCenter) {
- [[UAMessageCenter shared].defaultUI dismissMessageCenterAnimated:animated];
- }
-}
-
-- (void)inboxUpdated {
- UA_LDEBUG(@"Inbox updated");
- [self fireEvent:[UACordovaInboxUpdatedEvent event]];
-}
-
-#pragma mark -
-#pragma mark UAPushNotificationDelegate
-
--(void)receivedForegroundNotification:(NSDictionary *)userInfo completionHandler:(void (^)(void))completionHandler {
- UA_LDEBUG(@"Received a notification while the app was already in the foreground %@", userInfo);
-
- [self fireEvent:[UACordovaPushEvent eventWithNotificationContent:userInfo]];
-
- completionHandler();
-}
-
-- (void)receivedBackgroundNotification:(NSDictionary *)userInfo
- completionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
-
- UA_LDEBUG(@"Received a background notification %@", userInfo);
-
- [self fireEvent:[UACordovaPushEvent eventWithNotificationContent:userInfo]];
-
- completionHandler(UIBackgroundFetchResultNoData);
-}
-
--(void)receivedNotificationResponse:(UNNotificationResponse *)notificationResponse completionHandler:(void (^)(void))completionHandler {
- UA_LDEBUG(@"The application was launched or resumed from a notification %@", notificationResponse);
-
- UACordovaNotificationOpenedEvent *event = [UACordovaNotificationOpenedEvent eventWithNotificationResponse:notificationResponse];
- self.lastReceivedNotificationResponse = event.data;
- [self fireEvent:event];
-
- completionHandler();
-}
-
-- (UNNotificationPresentationOptions)extendPresentationOptions:(UNNotificationPresentationOptions)options notification:(UNNotification *)notification {
- if ([[self configValueForKey:NotificationPresentationAlertKey] boolValue]) {
- options = options | UNNotificationPresentationOptionAlert;
- }
-
- if ([[self configValueForKey:NotificationPresentationBadgeKey] boolValue]) {
- options = options | UNNotificationPresentationOptionBadge;
- }
-
- if ([[self configValueForKey:NotificationPresentationSoundKey] boolValue]) {
- options = options | UNNotificationPresentationOptionSound;
- }
-
- return options;
-}
-
-#pragma mark -
-#pragma mark UADeepLinkDelegate
-
--(void)receivedDeepLink:(NSURL *_Nonnull)url completionHandler:(void (^_Nonnull)(void))completionHandler {
- self.lastReceivedDeepLink = [url absoluteString];
- [self fireEvent:[UACordovaDeepLinkEvent eventWithDeepLink:url]];
- completionHandler();
-}
-
-#pragma mark -
-#pragma mark Channel Registration Events
-
-- (void)channelRegistrationSucceeded:(NSNotification *)notification {
- NSString *channelID = notification.userInfo[UAChannel.channelIdentifierKey];
- NSString *deviceToken = [UAirship push].deviceToken;
-
- UA_LINFO(@"Channel registration successful %@.", channelID);
-
- [self fireEvent:[UACordovaRegistrationEvent registrationSucceededEventWithChannelID:channelID deviceToken:deviceToken]];
-}
-
-- (void)channelRegistrationFailed {
- UA_LINFO(@"Channel registration failed.");
- [self fireEvent:[UACordovaRegistrationEvent registrationFailedEvent]];
-}
-
-#pragma mark -
-#pragma mark UARegistrationDelegate
-
-- (void)notificationAuthorizedSettingsDidChange:(UAAuthorizedNotificationSettings)authorizedSettings {
- UACordovaNotificationOptInEvent *event = [UACordovaNotificationOptInEvent eventWithAuthorizedSettings:authorizedSettings];
- [self fireEvent:event];
-}
-
-- (void)fireEvent:(NSObject *)event {
- id strongDelegate = self.delegate;
-
- if (strongDelegate && [strongDelegate notifyListener:event.type data:event.data]) {
- UA_LTRACE(@"Cordova plugin manager delegate notified with event of type:%@ with data:%@", event.type, event.data);
-
- return;
- }
-
- UA_LTRACE(@"No cordova plugin manager delegate available, storing pending event of type:%@ with data:%@", event.type, event.data);
-
- // Add pending event
- [self.pendingEvents addObject:event];
-}
-
-- (void)setDelegate:(id)delegate {
- _delegate = delegate;
-
- if (delegate) {
- @synchronized(self.pendingEvents) {
- UA_LTRACE(@"Cordova plugin manager delegate set:%@", delegate);
-
- NSDictionary *events = [self.pendingEvents copy];
- [self.pendingEvents removeAllObjects];
-
- for (NSObject *event in events) {
- [self fireEvent:event];
- }
- }
- }
-}
-
-#pragma mark -
-#pragma mark UAPreferenceCenterOpenDelegate
-
-- (BOOL)openPreferenceCenter:(NSString * _Nonnull)preferenceCenterID {
- BOOL useCustomUi = [[NSUserDefaults standardUserDefaults] boolForKey:[self preferenceCenterUIKey:preferenceCenterID]];
- if (useCustomUi) {
- [self fireEvent:[UACordovaPreferenceCenterEvent eventWithPreferenceCenterId:preferenceCenterID]];
- }
- return useCustomUi;
-}
-
-- (void)setPreferenceCenter:(NSString *)preferenceCenterID useCustomUI:(BOOL)useCustomUI {
- [[NSUserDefaults standardUserDefaults] setBool:useCustomUI forKey:[self preferenceCenterUIKey:preferenceCenterID]];
-}
-
-- (NSString *)preferenceCenterUIKey:(NSString *)preferenceCenterID {
- return [NSString stringWithFormat:@"com.urbanairship.preference_%@_custom_ui", preferenceCenterID];
-}
-
-@end
diff --git a/urbanairship-cordova/src/ios/UAMessageViewController.h b/urbanairship-cordova/src/ios/UAMessageViewController.h
deleted file mode 100644
index 0d009ec7..00000000
--- a/urbanairship-cordova/src/ios/UAMessageViewController.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#if __has_include("AirshipLib.h")
-#import "AirshipLib.h"
-#import "AirshipMessageCenterLib.h"
-#else
-@import AirshipKit;
-#endif
-
-@interface UAMessageViewController : UINavigationController
-
-- (void)loadMessageForID:(nullable NSString *)messageID;
-
-@end
-
diff --git a/urbanairship-cordova/src/ios/UAMessageViewController.m b/urbanairship-cordova/src/ios/UAMessageViewController.m
deleted file mode 100644
index eda2999d..00000000
--- a/urbanairship-cordova/src/ios/UAMessageViewController.m
+++ /dev/null
@@ -1,179 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UAMessageViewController.h"
-
-@interface UAMessageViewController()
-@property (nonatomic, copy) NSString *pendingMessageID;
-@property (nonatomic, strong) UADefaultMessageCenterMessageViewController *airshipMessageViewController;
-@end
-
-@implementation UAMessageViewController
-
-- (void)viewDidLoad {
- [super viewDidLoad];
-
- self.airshipMessageViewController = [[UADefaultMessageCenterMessageViewController alloc]
- initWithNibName:@"UADefaultMessageCenterMessageViewController"
- bundle:[UAMessageCenterResources bundle]];
- self.airshipMessageViewController.delegate = self;
-
-
- UIBarButtonItem *done = [[UIBarButtonItem alloc]
- initWithBarButtonSystemItem:UIBarButtonSystemItemDone
- target:self
- action:@selector(inboxMessageDone:)];
-
- self.airshipMessageViewController.navigationItem.leftBarButtonItem = done;
-
- self.viewControllers = @[self.airshipMessageViewController];
-
- if (self.pendingMessageID) {
- [self.airshipMessageViewController loadMessageForID:self.pendingMessageID];
- self.pendingMessageID = nil;
- }
-}
-
-- (void)viewDidLayoutSubviews {
- self.airshipMessageViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:UAMessageCenterLocalizedString(@"ua_delete_message")
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(delete:)];
- self.airshipMessageViewController.navigationItem.rightBarButtonItem.accessibilityHint = UAMessageCenterLocalizedString(@"ua_delete_message_description");
-
-}
-
-- (void)inboxMessageDone:(id)sender {
- [self dismissViewControllerAnimated:true completion:nil];
-}
-
-- (void)loadMessageForID:(NSString *)messageID {
- if (self.airshipMessageViewController) {
- [self.airshipMessageViewController loadMessageForID:messageID];
- self.pendingMessageID = nil;
- } else {
- self.pendingMessageID = messageID;
- }
-}
-
-#pragma mark UAMessageCenterMessageViewDelegate
-
-- (void)delete:(nullable id)sender {
- [self.airshipMessageViewController delete:sender];
- [self dismissViewControllerAnimated:YES completion:nil];
-}
-
-- (void)messageClosed:(NSString *)messageID {
- [self dismissViewControllerAnimated:YES completion:nil];
-}
-
-- (void)messageLoadStarted:(NSString *)messageID {
- // no-op
-}
-
-- (void)messageLoadSucceeded:(NSString *)messageID {
- // no-op
-}
-
-- (void)displayFailedToLoadAlertOnOK:(void (^)(void))okCompletion onRetry:(void (^)(void))retryCompletion {
- UIAlertController* alert = [UIAlertController alertControllerWithTitle:UAMessageCenterLocalizedString(@"ua_connection_error")
- message:UAMessageCenterLocalizedString(@"ua_mc_failed_to_load")
- preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:UAMessageCenterLocalizedString(@"ua_ok")
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction * action) {
- if (okCompletion) {
- okCompletion();
- }
- }];
-
- [alert addAction:defaultAction];
-
- if (retryCompletion) {
- UIAlertAction *retryAction = [UIAlertAction actionWithTitle:UAMessageCenterLocalizedString(@"ua_retry_button")
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction * _Nonnull action) {
- if (retryCompletion) {
- retryCompletion();
- }
- }];
-
- [alert addAction:retryAction];
- }
-
- [self presentViewController:alert animated:YES completion:nil];
-}
-
-- (void)displayNoLongerAvailableAlertOnOK:(void (^)(void))okCompletion {
- UIAlertController* alert = [UIAlertController alertControllerWithTitle:UAMessageCenterLocalizedString(@"ua_content_error")
- message:UAMessageCenterLocalizedString(@"ua_mc_no_longer_available")
- preferredStyle:UIAlertControllerStyleAlert];
-
- UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:UAMessageCenterLocalizedString(@"ua_ok")
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction * action) {
- if (okCompletion) {
- okCompletion();
- }
- }];
-
- [alert addAction:defaultAction];
-
- [self presentViewController:alert animated:YES completion:nil];
-}
-
-- (void)messageLoadFailed:(NSString *)messageID error:(NSError *)error {
- UA_LTRACE(@"message load failed: %@", messageID);
-
- void (^retry)(void) = ^{
- UA_WEAKIFY(self);
- [self displayFailedToLoadAlertOnOK:^{
- UA_STRONGIFY(self)
- [self dismissViewControllerAnimated:true completion:nil];
- } onRetry:^{
- UA_STRONGIFY(self)
- [self loadMessageForID:messageID];
- }];
- };
-
- void (^handleFailed)(void) = ^{
- UA_WEAKIFY(self);
- [self displayFailedToLoadAlertOnOK:^{
- UA_STRONGIFY(self)
- [self dismissViewControllerAnimated:true completion:nil];
- } onRetry:nil];
- };
-
- void (^handleExpired)(void) = ^{
- UA_WEAKIFY(self);
- [self displayNoLongerAvailableAlertOnOK:^{
- UA_STRONGIFY(self)
- [self dismissViewControllerAnimated:true completion:nil];
- }];
- };
-
- if ([error.domain isEqualToString:UAMessageCenterMessageLoadErrorDomain]) {
- if (error.code == UAMessageCenterMessageLoadErrorCodeFailureStatus) {
- // Encountered a failure status code
- NSUInteger status = [error.userInfo[UAMessageCenterMessageLoadErrorHTTPStatusKey] unsignedIntValue];
-
- if (status >= 500) {
- retry();
- } else if (status == 410) {
- // Gone: message has been permanently deleted from the backend.
- handleExpired();
- } else {
- handleFailed();
- }
- } else if (error.code == UAMessageCenterMessageLoadErrorCodeMessageExpired) {
- handleExpired();
- } else {
- retry();
- }
- } else {
- // Other errors
- retry();
- }
-}
-@end
-
diff --git a/urbanairship-cordova/src/ios/UAirshipPlugin.h b/urbanairship-cordova/src/ios/UAirshipPlugin.h
deleted file mode 100644
index 8fbfe64a..00000000
--- a/urbanairship-cordova/src/ios/UAirshipPlugin.h
+++ /dev/null
@@ -1,533 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import
-#import
-
-#if __has_include("AirshipLib.h")
-#import "AirshipLib.h"
-#import "AirshipMessageCenterLib.h"
-#import "AirshipAutomationLib.h"
-#else
-@import AirshipKit;
-#endif
-
-/**
- * The Urban Airship Cordova plugin.
- */
-@interface UAirshipPlugin : CDVPlugin
-
-/**
- * Sets the Urban Airship config and attempts takeOff.
- *
- * Expected arguments: NSDictionary
- *
- * @param command The cordova command.
- */
-- (void)takeOff:(CDVInvokedUrlCommand *)command;
-
-/**
- * Sets the default behavior when the message center is launched from a push
- * notification. If set to false the message center must be manually launched.
- *
- * Expected arguments: Boolean
- *
- * @param command The cordova command.
- */
-- (void)setAutoLaunchDefaultMessageCenter:(CDVInvokedUrlCommand *)command;
-
-/**
- * Enables or disables user push notifications.
- *
- * Expected arguments: Boolean
- *
- * @param command The cordova command.
- */
-- (void)setUserNotificationsEnabled:(CDVInvokedUrlCommand *)command;
-
-/**
- * Enables user push notifications.
- *
- * @param command The cordova command.
- */
-- (void)enableUserNotifications:(CDVInvokedUrlCommand *)command;
-
-/**
- * Checks if user push notifications are enabled or not.
- *
- * @param command The cordova command.
- */
-- (void)isUserNotificationsEnabled:(CDVInvokedUrlCommand *)command;
-
-/**
- * Returns the last notification that launched the application.
- *
- * Expected arguments: Boolean - `YES` to clear the notification.
- *
- * @param command The cordova command.
- */
-- (void)getLaunchNotification:(CDVInvokedUrlCommand *)command;
-
-/**
- * Returns the last received deep link.
- *
- * Expected arguments: Boolean - `YES` to clear the deep link.
- *
- * @param command The cordova command.
- */
-- (void)getDeepLink:(CDVInvokedUrlCommand *)command;
-
-/**
- * Returns the channel ID.
- *
- * @param command The cordova command.
- */
-- (void)getChannelID:(CDVInvokedUrlCommand *)command;
-
-/**
- * Returns the tags as an array.
- *
- * @param command The cordova command.
- */
-- (void)getTags:(CDVInvokedUrlCommand *)command;
-
-/**
- * Sets the tags.
- *
- * Expected arguments: An array of Strings
- *
- * @param command The cordova command.
- */
-- (void)setTags:(CDVInvokedUrlCommand *)command;
-
-/**
- * Returns the current badge number.
- *
- * @param command The cordova command.
- */
-- (void)getBadgeNumber:(CDVInvokedUrlCommand *)command;
-
-/**
- * Enables or disables auto badge. Defaults to `NO`.
- *
- * Expected arguments: Boolean
- *
- * @param command The cordova command.
- */
-- (void)setAutobadgeEnabled:(CDVInvokedUrlCommand *)command;
-
-/**
- * Sets the badge number.
- *
- * Expected arguments: Number
- *
- * @param command The cordova command.
- */
-- (void)setBadgeNumber:(CDVInvokedUrlCommand *)command;
-
-/**
- * Clears the badge.
- *
- * @param command The cordova command.
- */
-- (void)resetBadge:(CDVInvokedUrlCommand *)command;
-
-/**
- * Sets the named user ID.
- *
- * Expected arguments: String
- *
- * @param command The cordova command.
- */
-- (void)setNamedUser:(CDVInvokedUrlCommand *)command;
-
-/**
- * Returns the named user ID.
- *
- * Expected arguments: String
- *
- * @param command The cordova command.
- */
-- (void)getNamedUser:(CDVInvokedUrlCommand *)command;
-
-/**
- * Enables or disables quiet time.
- *
- * Expected arguments: Boolean
- *
- * @param command The cordova command.
- */
-- (void)setQuietTimeEnabled:(CDVInvokedUrlCommand *)command;
-
-/**
- * Checks if quiet time is currently enabled.
- *
- * @param command The cordova command.
- */
-- (void)isQuietTimeEnabled:(CDVInvokedUrlCommand *)command;
-
-/**
- * Sets the quiet time.
- *
- * Expected arguments: Number - start hour, Number - start minute,
- * Number - end hour, Number - end minute
- *
- * @param command The cordova command.
- */
-- (void)setQuietTime:(CDVInvokedUrlCommand *)command;
-
-/**
- * Returns the quiet time as an object with the following:
- * "startHour": Number,
- * "startMinute": Number,
- * "endHour": Number,
- * "endMinute": Number
- *
- * @param command The cordova command.
- */
-- (void)getQuietTime:(CDVInvokedUrlCommand *)command;
-
-/**
- * Checks if the device is currently in quiet time.
- *
- * @param command The cordova command.
- */
-- (void)isInQuietTime:(CDVInvokedUrlCommand *)command;
-
-/**
- * Sets the user notification types. Defaults to all notification types.
- *
- * Expected arguments: Number - bitmask of the notification types
- *
- * @param command The cordova command.
- */
-- (void)setNotificationTypes:(CDVInvokedUrlCommand *)command;
-
-/**
- * Sets notification presentation options.
- *
- * Expected arguments: Number - bitmask of the notification options
- *
- * @param command The cordova command.
- */
-- (void)setPresentationOptions:(CDVInvokedUrlCommand *)command;
-
-/**
- * Enables or disables analytics.
- *
- * Disabling analytics will delete any locally stored events
- * and prevent any events from uploading. Features that depend on analytics being
- * enabled may not work properly if it's disabled (reports, region triggers,
- * location segmentation, push to local time).
- *
- * Expected arguments: Boolean
- *
- * @param command The cordova command.
- */
-- (void)setAnalyticsEnabled:(CDVInvokedUrlCommand *)command;
-
-/**
- * Sets associated custom identifiers for use with the Connect data stream.
- *
- * Previous identifiers will be replaced by the new identifiers each time setAssociateIdentifier is called. It is a set operation.
- *
- * Expected arguments: An array of strings containing the identifier and key.
- *
- * @param command The cordova command.
- */
-- (void)setAssociatedIdentifier:(CDVInvokedUrlCommand *)command;
-
-/**
- * Checks if analytics is enabled or not.
- *
- * @param command The cordova command.
- */
-- (void)isAnalyticsEnabled:(CDVInvokedUrlCommand *)command;
-
-/**
- * Runs an Urban Airship action.
- *
- * Expected arguments: String - action name, * - the action value
- *
- * @param command The cordova command.
- */
-- (void)runAction:(CDVInvokedUrlCommand *)command;
-
-/**
- * Edits the named user tag groups.
- *
- * Expected arguments: An array of objects that contain:
- * "operation": String, either "add" or "remove",
- * "group": String, the tag group,
- * "tags": Array of tags
- *
- * @param command The cordova command.
- */
-- (void)editNamedUserTagGroups:(CDVInvokedUrlCommand *)command;
-
-/**
- * Edits the channel tag groups.
- *
- * Expected arguments: An array of objects that contain:
- * "operation": String, either "add" or "remove",
- * "group": String, the tag group,
- * "tags": Array of tags
- *
- * @param command The cordova command.
- */
-- (void)editChannelTagGroups:(CDVInvokedUrlCommand *)command;
-
-/**
- * Edits the channel attributes.
- *
- * Expected arguments: An array of objects that contain:
- * "action": String, either `remove` or `set`
- * "key": String, the attribute name.
- * "value": String, the attribute value.
- *
- * @param command The cordova command.
- */
-- (void)editChannelAttributes:(CDVInvokedUrlCommand *)command;
-
-/**
- * Edits the named user attributes.
- *
- * Expected arguments: An array of objects that contain:
- * "action": String, either `remove` or `set`
- * "key": String, the attribute name.
- * "value": String, the attribute value.
- *
- * @param command The cordova command.
- */
-- (void)editNamedUserAttributes:(CDVInvokedUrlCommand *)command;
-
-/**
- * Registers a listener for events.
- *
- * @param command The cordova command.
- */
-- (void)registerListener:(CDVInvokedUrlCommand *)command;
-
-/**
- * Display the given message without animation.
- *
- * @param command The cordova command.
- */
-- (void)displayMessageCenter:(CDVInvokedUrlCommand *)command;
-
-/**
- * Dismiss the message center.
- *
- * @param command The cordova command.
- */
-- (void)dismissMessageCenter:(CDVInvokedUrlCommand *)command;
-
-/**
- * Gets the inbox listing.
- *
- * @param command The cordova command.
- */
-- (void)getInboxMessages:(CDVInvokedUrlCommand *)command;
-
-/**
- * Marks an inbox message read.
- *
- * Expected arguments: String - message ID.
- *
- * @param command The cordova command.
- */
-- (void)markInboxMessageRead:(CDVInvokedUrlCommand *)command;
-
-/**
- * Deletes an inbox message.
- *
- * Expected arguments: String - message ID.
- *
- * @param command The cordova command.
- */
-- (void)deleteInboxMessage:(CDVInvokedUrlCommand *)command;
-
-/**
- * Displays an inbox message.
- *
- * Expected arguments: String - message ID.
- *
- * @param command The cordova command.
- */
-- (void)displayInboxMessage:(CDVInvokedUrlCommand *)command;
-
-/**
- * Dismiss an inbox message.
- *
- * @param command The cordova command.
- */
-- (void)dismissInboxMessage:(CDVInvokedUrlCommand *)command;
-
-/**
- * Refreshes the inbox.
- *
- * @param command The cordova command.
- */
-- (void)refreshInbox:(CDVInvokedUrlCommand *)command;
-
-/**
- * Checks if app notifications are enabled or not.
- *
- * @param command The cordova command.
- */
-- (void)isAppNotificationsEnabled:(CDVInvokedUrlCommand *)command;
-
-/**
- * Gets the currently active notifications.
- *
- * @param command The cordova command.
- */
-- (void)getActiveNotifications:(CDVInvokedUrlCommand *)command;
-
-/**
- * Clears notifications by identifier.
- *
- * Expected arguments: String - notification identifier.
- *
- * @param command The cordova command.
- */
-- (void)clearNotification:(CDVInvokedUrlCommand *)command;
-
-/**
- * Clears all notifications.
- *
- * @param command The cordova command.
- */
-- (void)clearNotifications:(CDVInvokedUrlCommand *)command;
-
-/**
- * Enables features, adding them to the set of currently enabled features.
- *
- * Expected arguments: NSArray - the features.
- *
- * @param command The cordova command.
- */
-- (void)enableFeature:(CDVInvokedUrlCommand *)command;
-
-/**
- * Disables features, removing them from the set of currently enabled features.
- *
- * Expected arguments: NSArray - the features.
- *
- * @param command The cordova command.
- */
-- (void)disableFeature:(CDVInvokedUrlCommand *)command;
-
-/**
- * Sets the current enabled features, replacing any currently enabled features with the given set.
- *
- * Expected arguments: NSArray - the features.
- *
- * @param command The cordova command.
- */
-- (void)setEnabledFeatures:(CDVInvokedUrlCommand *)command;
-
-/**
- * Gets the current enabled features.
- *
- * @param command The cordova command.
- */
-- (void)getEnabledFeatures:(CDVInvokedUrlCommand *)command;
-
-/**
- * Checks if all of the given features are enabled.
- *
- * Expected arguments: NSArray - the features.
- *
- * @param command The cordova command.
- */
-- (void)isFeatureEnabled:(CDVInvokedUrlCommand *)command;
-
-/**
- * Opens the Preference Center with the given preferenceCenterId.
- *
- * Expected arguments: String - the preference center id.
- *
- * @param command The cordova command.
- */
-- (void)openPreferenceCenter:(CDVInvokedUrlCommand *)command;
-
-
-/**
- * Gets the configuration of the Preference Center with the given Id trough a callback method.
- *
- * Expected arguments: String - the preference center Id.
- *
- * @param command The cordova command.
- */
-- (void)getPreferenceCenterConfig:(CDVInvokedUrlCommand *)command;
-
-/**
- * Set to true of override the preference center UI
- *
- * Expected arguments: An array of objects that contain:
- * "preferenceCenterId": the preference center Id.
- * "userCustomUi": Boolean: true to use your custom preference center otherwise set to false.
- *
- * @param command The cordova command.
- */
-- (void)setUseCustomPreferenceCenterUi:(CDVInvokedUrlCommand *)command;
-
-/**
- * Edits channel subscription lists.
- *
- * Expected arguments: An array of objects that contain:
- * "operation": String, either `subscribe` or `unsubscribe`
- * "listId": String, the listID.
- *
- * @param command The cordova command.
- */
-- (void)editChannelSubscriptionLists:(CDVInvokedUrlCommand *)command;
-
-/**
- * Edits contact subscription lists.
- *
- * Expected arguments: An array of objects that contain:
- * "operation": String, either `subscribe` or `unsubscribe`
- * "listId": String, the listID.
- * "scope": Defines the channel types that the change applies to
- *
- * @param command The cordova command.
- */
-- (void)editContactSubscriptionLists:(CDVInvokedUrlCommand *)command;
-
-/**
- * Returns the current set of subscription lists for the current channel,
- * optionally applying pending subscription list changes that will be applied during the next channel update.
- *
- * @param command The cordova command.
- */
-- (void)getChannelSubscriptionLists:(CDVInvokedUrlCommand *)command;
-
-/**
- * Returns the current set of subscription lists for the current contact,
- * optionally applying pending subscription list changes that will be applied during the next contact update.
- *
- * @param command The cordova command.
- */
-- (void)getContactSubscriptionLists:(CDVInvokedUrlCommand *)command;
-
-/**
- * Returns the locale currently used by Airship.
- * @param command The cordova command.
- */
-- (void)getCurrentLocale:(CDVInvokedUrlCommand *)command;
-
-/**
- * Overrides the locale.
- * @param command The cordova command.
- */
-- (void)setCurrentLocale:(CDVInvokedUrlCommand *)command;
-
-/**
- * Resets the current locale.
- *
- * @param command The cordova command.
- */
-- (void)clearLocale:(CDVInvokedUrlCommand *)command ;
-
-@end
diff --git a/urbanairship-cordova/src/ios/UAirshipPlugin.m b/urbanairship-cordova/src/ios/UAirshipPlugin.m
deleted file mode 100644
index f1cff661..00000000
--- a/urbanairship-cordova/src/ios/UAirshipPlugin.m
+++ /dev/null
@@ -1,1214 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UAirshipPlugin.h"
-#import "UACordovaPluginManager.h"
-#import "UACordovaPushEvent.h"
-#import "UAMessageViewController.h"
-
-#if __has_include("AirshipLib.h")
-#import "AirshipLib.h"
-#import "AirshipMessageCenterLib.h"
-#import "AirshipAutomationLib.h"
-#else
-@import AirshipKit;
-#endif
-
-NSString *const PreferenceCenterIdKey = @"id";
-NSString *const PreferenceCenterSectionsKey = @"sections";
-NSString *const PreferenceCenterDisplayKey = @"display";
-NSString *const PreferenceCenterDisplayNameKey = @"name";
-NSString *const PreferenceCenterDisplayDescriptionKey = @"description";
-NSString *const PreferenceCenterItemsKey = @"items";
-NSString *const PreferenceCenterSubscriptionIdKey = @"subscriptionId";
-NSString *const PreferenceCenterComponentsKey = @"components";
-NSString *const PreferenceCenterScopesKey = @"scopes";
-NSString *const PreferenceCenterScopeWebKey = @"web";
-NSString *const PreferenceCenterScopeEmailKey = @"email";
-NSString *const PreferenceCenterScopeAppKey = @"app";
-NSString *const PreferenceCenterScopeSmsKey = @"sms";
-
-typedef void (^UACordovaCompletionHandler)(CDVCommandStatus, id);
-typedef void (^UACordovaExecutionBlock)(NSArray *args, UACordovaCompletionHandler completionHandler);
-
-@interface UAirshipPlugin()
-@property (nonatomic, copy) NSString *listenerCallbackID;
-@property (nonatomic, weak) UAMessageViewController *messageViewController;
-@property (nonatomic, strong) UACordovaPluginManager *pluginManager;
-@property (nonatomic, weak) UAInAppMessageHTMLAdapter *htmlAdapter;
-@property (nonatomic, assign) BOOL factoryBlockAssigned;
-@end
-
-@implementation UAirshipPlugin
-
-- (void)pluginInitialize {
- UA_LINFO(@"Initializing UrbanAirship cordova plugin.");
-
- if (!self.pluginManager) {
- self.pluginManager = [UACordovaPluginManager pluginManagerWithDefaultConfig:self.commandDelegate.settings];
- }
-
- UA_LDEBUG(@"pluginIntialize called:plugin initializing and attempting takeOff with pluginManager:%@", self.pluginManager);
- [self.pluginManager attemptTakeOff];
-}
-
-- (void)dealloc {
- self.pluginManager.delegate = nil;
- self.listenerCallbackID = nil;
-}
-
-/**
- * Helper method to create a plugin result with the specified value.
- *
- * @param value The result's value.
- * @param status The result's status.
- * @returns A CDVPluginResult with specified value.
- */
-- (CDVPluginResult *)pluginResultForValue:(id)value status:(CDVCommandStatus)status {
- /*
- NSString -> String
- NSNumber --> (Integer | Double)
- NSArray --> Array
- NSDictionary --> Object
- NSNull --> no return value
- nil -> no return value
- */
-
- // String
- if ([value isKindOfClass:[NSString class]]) {
- NSCharacterSet *characters = [NSCharacterSet URLHostAllowedCharacterSet];
- return [CDVPluginResult resultWithStatus:status
- messageAsString:[value stringByAddingPercentEncodingWithAllowedCharacters:characters]];
- }
-
- // Number
- if ([value isKindOfClass:[NSNumber class]]) {
- CFNumberType numberType = CFNumberGetType((CFNumberRef)value);
- //note: underlyingly, BOOL values are typedefed as char
- if (numberType == kCFNumberIntType || numberType == kCFNumberCharType) {
- return [CDVPluginResult resultWithStatus:status messageAsInt:[value intValue]];
- } else {
- return [CDVPluginResult resultWithStatus:status messageAsDouble:[value doubleValue]];
- }
- }
-
- // Array
- if ([value isKindOfClass:[NSArray class]]) {
- return [CDVPluginResult resultWithStatus:status messageAsArray:value];
- }
-
- // Object
- if ([value isKindOfClass:[NSDictionary class]]) {
- return [CDVPluginResult resultWithStatus:status messageAsDictionary:value];
- }
-
- // Null
- if ([value isKindOfClass:[NSNull class]]) {
- return [CDVPluginResult resultWithStatus:status];
- }
-
- // Nil
- if (!value) {
- return [CDVPluginResult resultWithStatus:status];
- }
-
- UA_LERR(@"Cordova callback block returned unrecognized type: %@", NSStringFromClass([value class]));
- return [CDVPluginResult resultWithStatus:status];
-}
-
-/**
- * Helper method to perform a cordova command.
- *
- * @param command The cordova command.
- * @param block The UACordovaExecutionBlock to execute.
- */
-- (void)performCallbackWithCommand:(CDVInvokedUrlCommand *)command withBlock:(UACordovaExecutionBlock)block {
- [self performCallbackWithCommand:command airshipRequired:YES withBlock:block];
-}
-
-/**
- * Helper method to perform a cordova command.
- *
- * @param command The cordova command.
- * @param block The UACordovaExecutionBlock to execute.
- */
-- (void)performCallbackWithCommand:(CDVInvokedUrlCommand *)command
- airshipRequired:(BOOL)airshipRequired
- withBlock:(UACordovaExecutionBlock)block {
-
- if (airshipRequired && !self.pluginManager.isAirshipReady) {
- UA_LERR(@"Unable to run Urban Airship command. Takeoff not called.");
- id result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"TakeOff not called."];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- return;
- }
-
- UACordovaCompletionHandler completionHandler = ^(CDVCommandStatus status, id value) {
- CDVPluginResult *result = [self pluginResultForValue:value status:status];
- [self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
- };
-
- if (!block) {
- completionHandler(CDVCommandStatus_OK, nil);
- } else {
- block(command.arguments, completionHandler);
- }
-}
-
-#pragma mark Cordova bridge
-
-- (void)registerListener:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"registerListener called with command: %@ and callback ID:%@", command, command.callbackId);
-
- self.listenerCallbackID = command.callbackId;
-
- if (self.listenerCallbackID) {
- self.pluginManager.delegate = self;
- }
-}
-
-- (void)takeOff:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"takeOff called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command
- airshipRequired:NO
- withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- UA_LDEBUG(@"Performing takeOff with args: %@", args);
-
- NSDictionary *config = [args objectAtIndex:0];
- if (!config[@"production"] || !config[@"development"]) {
- completionHandler(CDVCommandStatus_ERROR, @"Invalid config");
- return;
- }
-
- if (self.pluginManager.isAirshipReady) {
- UA_LINFO(@"TakeOff already called. Config will be applied next app start.");
- }
-
- NSDictionary *development = config[@"development"];
- [self.pluginManager setDevelopmentAppKey:development[@"appKey"] appSecret:development[@"appSecret"]];
-
- NSDictionary *production = config[@"production"];
- [self.pluginManager setProductionAppKey:production[@"appKey"] appSecret:production[@"appSecret"]];
-
- [self.pluginManager setCloudSite:config[@"site"]];
- [self.pluginManager setMessageCenterStyleFile:config[@"messageCenterStyleConfig"]];
-
- if (!self.pluginManager.isAirshipReady) {
- [self.pluginManager attemptTakeOff];
- if (!self.pluginManager.isAirshipReady) {
- completionHandler(CDVCommandStatus_ERROR, @"Invalid config. Airship unable to takeOff.");
- }
- }
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)setAutoLaunchDefaultMessageCenter:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setAutoLaunchDefaultMessageCenter called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- BOOL enabled = [[args objectAtIndex:0] boolValue];
- self.pluginManager.autoLaunchMessageCenter = enabled;
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)setNotificationTypes:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setNotificationTypes called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- UANotificationOptions types = [[args objectAtIndex:0] intValue];
-
- UA_LDEBUG(@"Setting notification types: %ld", (long)types);
- [UAirship push].notificationOptions = types;
- [[UAirship push] updateRegistration];
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)setPresentationOptions:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setPresentationOptions called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- UNNotificationPresentationOptions options = [[args objectAtIndex:0] intValue];
-
- UA_LDEBUG(@"Setting presentation options types: %ld", (long)options);
- [self.pluginManager setPresentationOptions:(NSUInteger)options];
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)setUserNotificationsEnabled:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setUserNotificationsEnabled called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- BOOL enabled = [[args objectAtIndex:0] boolValue];
-
- UA_LTRACE(@"setUserNotificationsEnabled set to:%@", enabled ? @"true" : @"false");
-
- [UAirship push].userPushNotificationsEnabled = enabled;
-
- //forces a reregistration
- [[UAirship push] updateRegistration];
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)enableUserNotifications:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"enableUserNotifications called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- [[UAirship push] enableUserPushNotifications:^(BOOL success) {
- completionHandler(CDVCommandStatus_OK, [NSNumber numberWithBool:success]);
- }];
- }];
-}
-
-- (void)setAssociatedIdentifier:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setAssociatedIdentifier called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSString *key = [args objectAtIndex:0];
- NSString *identifier = [args objectAtIndex:1];
-
- UAAssociatedIdentifiers *identifiers = [UAirship.analytics currentAssociatedDeviceIdentifiers];
- [identifiers setIdentifier:identifier forKey:key];
- [UAirship.analytics associateDeviceIdentifiers:identifiers];
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)setAnalyticsEnabled:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setAnalyticsEnabled called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSNumber *value = [args objectAtIndex:0];
- BOOL enabled = [value boolValue];
- if (enabled) {
- [[UAirship shared].privacyManager enableFeatures:UAFeaturesAnalytics];
- } else {
- [[UAirship shared].privacyManager disableFeatures:UAFeaturesAnalytics];
- }
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)isAnalyticsEnabled:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"isAnalyticsEnabled called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- BOOL enabled = [[UAirship shared].privacyManager isEnabled:UAFeaturesAnalytics];
-
- completionHandler(CDVCommandStatus_OK, [NSNumber numberWithBool:enabled]);
- }];
-}
-
-- (void)isUserNotificationsEnabled:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"isUserNotificationsEnabled called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- BOOL enabled = [UAirship push].userPushNotificationsEnabled;
- completionHandler(CDVCommandStatus_OK, [NSNumber numberWithBool:enabled]);
- }];
-}
-
-- (void)isQuietTimeEnabled:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"isQuietTimeEnabled called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- BOOL enabled = [UAirship push].quietTimeEnabled;
- completionHandler(CDVCommandStatus_OK, [NSNumber numberWithBool:enabled]);
- }];
-}
-
-- (void)isInQuietTime:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"isInQuietTime called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- BOOL inQuietTime;
- NSDictionary *quietTimeDictionary = [UAirship push].quietTime;
- if (quietTimeDictionary) {
- NSString *start = [quietTimeDictionary valueForKey:@"start"];
- NSString *end = [quietTimeDictionary valueForKey:@"end"];
-
- NSDateFormatter *df = [NSDateFormatter new];
- df.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
- df.dateFormat = @"HH:mm";
-
- NSDate *startDate = [df dateFromString:start];
- NSDate *endDate = [df dateFromString:end];
-
- NSDate *now = [NSDate date];
-
- inQuietTime = ([now earlierDate:startDate] == startDate && [now earlierDate:endDate] == now);
- } else {
- inQuietTime = NO;
- }
-
- completionHandler(CDVCommandStatus_OK, [NSNumber numberWithBool:inQuietTime]);
- }];
-}
-
-- (void)getLaunchNotification:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getLaunchNotification called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- id event = self.pluginManager.lastReceivedNotificationResponse;
-
- if ([args firstObject]) {
- self.pluginManager.lastReceivedNotificationResponse = nil;
- }
-
- completionHandler(CDVCommandStatus_OK, event);
- }];
-}
-
-- (void)getDeepLink:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getDeepLink called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSString *deepLink = self.pluginManager.lastReceivedDeepLink;
-
- if ([args firstObject]) {
- self.pluginManager.lastReceivedDeepLink = nil;
- }
-
- completionHandler(CDVCommandStatus_OK, deepLink);
- }];
-}
-
-- (void)getChannelID:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getChannelID called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- completionHandler(CDVCommandStatus_OK, [UAirship channel].identifier ?: @"");
- }];
-}
-
-- (void)getQuietTime:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getQuietTime called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSDictionary *quietTimeDictionary = [UAirship push].quietTime;
-
- if (quietTimeDictionary) {
-
- NSString *start = [quietTimeDictionary objectForKey:@"start"];
- NSString *end = [quietTimeDictionary objectForKey:@"end"];
-
- NSDateFormatter *df = [NSDateFormatter new];
- df.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
- df.dateFormat = @"HH:mm";
-
- NSDate *startDate = [df dateFromString:start];
- NSDate *endDate = [df dateFromString:end];
-
- // these will be nil if the dateformatter can't make sense of either string
- if (startDate && endDate) {
- NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
- NSDateComponents *startComponents = [gregorian components:NSCalendarUnitHour|NSCalendarUnitMinute fromDate:startDate];
- NSDateComponents *endComponents = [gregorian components:NSCalendarUnitHour|NSCalendarUnitMinute fromDate:endDate];
-
- completionHandler(CDVCommandStatus_OK, @{ @"startHour": @(startComponents.hour),
- @"startMinute": @(startComponents.minute),
- @"endHour": @(endComponents.hour),
- @"endMinute": @(endComponents.minute) });
-
- return;
- }
- }
-
- completionHandler(CDVCommandStatus_OK, @{ @"startHour": @(0),
- @"startMinute": @(0),
- @"endHour": @(0),
- @"endMinute": @(0) });
- }];
-}
-
-- (void)getTags:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getTags called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- completionHandler(CDVCommandStatus_OK, [UAirship channel].tags ?: [NSArray array]);
- }];
-}
-
-- (void)getBadgeNumber:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getBadgeNumber called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- completionHandler(CDVCommandStatus_OK, @([UIApplication sharedApplication].applicationIconBadgeNumber));
- }];
-}
-
-- (void)getNamedUser:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getNamedUser called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- completionHandler(CDVCommandStatus_OK, UAirship.contact.namedUserID ?: @"");
- }];
-}
-
-- (void)setTags:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setTags called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSMutableArray *tags = [NSMutableArray arrayWithArray:[args objectAtIndex:0]];
- [UAirship channel].tags = tags;
- [[UAirship channel] updateRegistration];
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)setQuietTimeEnabled:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setQuietTimeEnabled called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSNumber *value = [args objectAtIndex:0];
- BOOL enabled = [value boolValue];
- [UAirship push].quietTimeEnabled = enabled;
- [[UAirship push] updateRegistration];
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)setQuietTime:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setQuietTime called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- id startHr = [args objectAtIndex:0];
- id startMin = [args objectAtIndex:1];
- id endHr = [args objectAtIndex:2];
- id endMin = [args objectAtIndex:3];
-
- [[UAirship push] setQuietTimeStartHour:[startHr integerValue] startMinute:[startMin integerValue] endHour:[endHr integerValue] endMinute:[endMin integerValue]];
- [[UAirship push] updateRegistration];
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)setAutobadgeEnabled:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setAutobadgeEnabled called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSNumber *number = [args objectAtIndex:0];
- BOOL enabled = [number boolValue];
- [UAirship push].autobadgeEnabled = enabled;
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)setBadgeNumber:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setBadgeNumber called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- id number = [args objectAtIndex:0];
- NSInteger badgeNumber = [number intValue];
- [[UAirship push] setBadgeNumber:badgeNumber];
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)setNamedUser:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setNamedUser called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSString *namedUserID = nil;
- if ([[args objectAtIndex:0] isKindOfClass:[NSString class]]) {
- namedUserID = [args objectAtIndex:0];
- namedUserID = [namedUserID stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- }
-
- if (namedUserID.length) {
- [UAirship.contact identify:namedUserID];
- } else {
- [UAirship.contact reset];
- }
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)editNamedUserTagGroups:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"editNamedUserTagGroups called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
-
- [UAirship.contact editTagGroups:^(UATagGroupsEditor * editor) {
- [self applyTagGroupEdits:[args objectAtIndex:0] editor:editor];
- }];
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)editChannelTagGroups:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"editChannelTagGroups called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
-
- [UAirship.channel editTagGroups:^(UATagGroupsEditor * editor) {
- [self applyTagGroupEdits:[args objectAtIndex:0] editor:editor];
- }];
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)applyTagGroupEdits:(NSDictionary *)edits editor:(UATagGroupsEditor *)editor {
- for (NSDictionary *edit in edits) {
- NSString *group = edit[@"group"];
- if ([edit[@"operation"] isEqualToString:@"add"]) {
- [editor addTags:edit[@"tags"] group:group];
- } else if ([edit[@"operation"] isEqualToString:@"remove"]) {
- [editor removeTags:edit[@"tags"] group:group];
- }
- }
-}
-
-- (void)applyAttributeEdits:(NSDictionary *)edits editor:(UAAttributesEditor *)editor {
- for (NSDictionary *edit in edits) {
- NSString *action = edit[@"action"];
- NSString *name = edit[@"key"];
-
- if ([action isEqualToString:@"set"]) {
- id value = edit[@"value"];
- NSString *valueType = edit[@"type"];
- if ([valueType isEqualToString:@"string"]) {
- [editor setString:value attribute:name];
- } else if ([valueType isEqualToString:@"number"]) {
- [editor setNumber:value attribute:name];
- } else if ([valueType isEqualToString:@"date"]) {
- // JavaScript's date type doesn't pass through the JS to native bridge. Dates are instead serialized as milliseconds since epoch.
- NSDate *date = [NSDate dateWithTimeIntervalSince1970:[(NSNumber *)value doubleValue] / 1000.0];
- [editor setDate:date attribute:name];
-
- } else {
- UA_LWARN(@"Unknown attribute type: %@", valueType);
- }
- } else if ([action isEqualToString:@"remove"]) {
- [editor removeAttribute:name];
- }
- }
-}
-
-- (void)editChannelSubscriptionLists:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"editChannelSubscriptionLists called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- [UAirship.channel editSubscriptionLists:^(UASubscriptionListEditor *editor) {
- for (NSDictionary *edit in [args objectAtIndex:0]) {
- NSString *listID = edit[@"listId"];
- NSString *operation = edit[@"operation"];
-
- if ([operation isEqualToString:@"subscribe"]) {
- [editor subscribe:listID];
- } else if ([operation isEqualToString:@"unsubscribe"]) {
- [editor unsubscribe:listID];
- }
- }
- }];
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)editContactSubscriptionLists:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"editContactSubscriptionLists called with command arguments: %@", command.arguments);
-
- NSArray *allChannelScope = @[@"sms", @"email", @"app", @"web"];
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- [UAirship.contact editSubscriptionLists:^(UAScopedSubscriptionListEditor *editor) {
- for (NSDictionary *edit in [args objectAtIndex:0]) {
- NSString *listID = edit[@"listId"];
- NSString *scope = edit[@"scope"];
- NSString *operation = edit[@"operation"];
-
- if ((listID != nil) & [allChannelScope containsObject:scope]) {
- UAChannelScope channelScope = [self getScope:scope];
- if ([operation isEqualToString:@"subscribe"]) {
- [editor subscribe:listID scope:channelScope];
- } else if ([operation isEqualToString:@"unsubscribe"]) {
- [editor unsubscribe:listID scope:channelScope];
- }
- }
- }
- }];
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (UAChannelScope)getScope:(NSString* )scope {
- if ([scope isEqualToString:@"sms"]) {
- return UAChannelScopeSms;
- } else if ([scope isEqualToString:@"email"]) {
- return UAChannelScopeEmail;
- } else if ([scope isEqualToString:@"app"]) {
- return UAChannelScopeApp;
- } else {
- return UAChannelScopeWeb;
- }
-}
-
-- (NSString *)getScopeString:(UAChannelScope )scope {
- switch (scope) {
- case UAChannelScopeSms:
- return @"sms";
- case UAChannelScopeEmail:
- return @"email";
- case UAChannelScopeApp:
- return @"app";
- case UAChannelScopeWeb:
- return @"web";
- }
-}
-
-- (void)getChannelSubscriptionLists:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getChannelSubscriptionLists called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
-
- [[UAChannel shared] fetchSubscriptionListsWithCompletionHandler:^(NSArray * _Nullable channelSubscriptionLists, NSError * _Nullable error) {
- if (error) {
- completionHandler(CDVCommandStatus_ERROR, error);
- }
- if (!channelSubscriptionLists) {
- completionHandler(CDVCommandStatus_ERROR, @"channel subscription list null");
- }
- completionHandler(CDVCommandStatus_OK, channelSubscriptionLists);
- }];
-
- }];
-}
-
-- (void)getContactSubscriptionLists:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getContactSubscriptionLists called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
-
- [[UAContact shared] fetchSubscriptionListsWithCompletionHandler:^(NSDictionary * _Nullable contactSubscriptionLists, NSError * _Nullable error) {
- if (error) {
- completionHandler(CDVCommandStatus_ERROR, error);
- }
- if (!contactSubscriptionLists) {
- completionHandler(CDVCommandStatus_ERROR, @"contact subscription list null");
- }
-
- NSMutableDictionary *contactSubscriptionListDict = [NSMutableDictionary dictionary];
- for (NSString* identifier in contactSubscriptionLists.allKeys) {
- UAChannelScopes *scopes = contactSubscriptionLists[identifier];
- NSMutableArray *scopesArray = [NSMutableArray array];
- for (id scope in scopes.values) {
- UAChannelScope channelScope = (UAChannelScope)[scope intValue];
- [scopesArray addObject:[self getScopeString:channelScope]];
- }
- [contactSubscriptionListDict setValue:scopesArray forKey:identifier];
- }
- completionHandler(CDVCommandStatus_OK, contactSubscriptionListDict);
- }];
-
- }];
-}
-
-
-- (void)resetBadge:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"resetBadge called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- [[UAirship push] resetBadge];
- [[UAirship push] updateRegistration];
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)trackScreen:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"trackScreen called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSString *screen = [args objectAtIndex:0];
-
- UA_LTRACE(@"trackScreen set to:%@", screen);
-
- [[UAirship analytics] trackScreen:screen];
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-- (void)runAction:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"runAction called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSString *actionName = [args firstObject];
- id actionValue = args.count >= 2 ? [args objectAtIndex:1] : nil;
-
- [UAActionRunner runActionWithName:actionName
- value:actionValue
- situation:UASituationManualInvocation
- completionHandler:^(UAActionResult *actionResult) {
-
- if (actionResult.status == UAActionStatusCompleted) {
-
- /*
- * We are wrapping the value in an object to be consistent
- * with the Android implementation.
- */
-
- NSMutableDictionary *result = [NSMutableDictionary dictionary];
- [result setValue:actionResult.value forKey:@"value"];
- completionHandler(CDVCommandStatus_OK, result);
- } else {
- NSString *error = [self errorMessageForAction:actionName result:actionResult];
- completionHandler(CDVCommandStatus_ERROR, error);
- }
- }];
-
- }];
-}
-
-- (void)isAppNotificationsEnabled:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"isAppNotificationsEnabled called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- BOOL optedIn = [UAirship push].authorizedNotificationSettings != 0;
- completionHandler(CDVCommandStatus_OK, [NSNumber numberWithBool:optedIn]);
- }];
-}
-
-/**
- * Helper method to create an error message from an action result.
- *
- * @param actionName The name of the action.
- * @param actionResult The action result.
- * @return An error message, or nil if no error was found.
- */
-- (NSString *)errorMessageForAction:(NSString *)actionName result:(UAActionResult *)actionResult {
- switch (actionResult.status) {
- case UAActionStatusActionNotFound:
- return [NSString stringWithFormat:@"Action %@ not found.", actionName];
- case UAActionStatusArgumentsRejected:
- return [NSString stringWithFormat:@"Action %@ rejected its arguments.", actionName];
- case UAActionStatusError:
- if (actionResult.error.localizedDescription) {
- return actionResult.error.localizedDescription;
- }
- case UAActionStatusCompleted:
- return nil;
- }
-
- return [NSString stringWithFormat:@"Action %@ failed with unspecified error", actionName];
-}
-
-
-- (void)displayMessageCenter:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"displayMessageCenter called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- [[UAMessageCenter shared] display];
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)dismissMessageCenter:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"dismissMessageCenter called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- [[UAMessageCenter shared] dismiss];
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)getInboxMessages:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getInboxMessages called with command arguments: %@", command.arguments);
- UA_LDEBUG(@"Getting messages");
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSMutableArray *messages = [NSMutableArray array];
-
- for (UAInboxMessage *message in [UAMessageCenter shared].messageList.messages) {
-
- NSDictionary *icons = [message.rawMessageObject objectForKey:@"icons"];
- NSString *iconUrl = [icons objectForKey:@"list_icon"];
- NSNumber *sentDate = @([message.messageSent timeIntervalSince1970] * 1000);
-
- NSMutableDictionary *messageInfo = [NSMutableDictionary dictionary];
- [messageInfo setValue:message.title forKey:@"title"];
- [messageInfo setValue:message.messageID forKey:@"id"];
- [messageInfo setValue:sentDate forKey:@"sentDate"];
- [messageInfo setValue:iconUrl forKey:@"listIconUrl"];
- [messageInfo setValue:message.unread ? @NO : @YES forKey:@"isRead"];
- [messageInfo setValue:message.extra forKey:@"extras"];
-
- [messages addObject:messageInfo];
- }
-
- completionHandler(CDVCommandStatus_OK, messages);
- }];
-}
-
-- (void)markInboxMessageRead:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"markInboxMessageRead called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSString *messageID = [command.arguments firstObject];
- UAInboxMessage *message = [[UAMessageCenter shared].messageList messageForID:messageID];
-
- if (!message) {
- NSString *error = [NSString stringWithFormat:@"Message not found: %@", messageID];
- completionHandler(CDVCommandStatus_ERROR, error);
- return;
- }
-
- [[UAMessageCenter shared].messageList markMessagesRead:@[message] completionHandler:nil];
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)deleteInboxMessage:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"deleteInboxMessage called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSString *messageID = [command.arguments firstObject];
- UAInboxMessage *message = [[UAMessageCenter shared].messageList messageForID:messageID];
-
- if (!message) {
- NSString *error = [NSString stringWithFormat:@"Message not found: %@", messageID];
- completionHandler(CDVCommandStatus_ERROR, error);
- return;
- }
-
- [[UAMessageCenter shared].messageList markMessagesDeleted:@[message] completionHandler:nil];
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)displayInboxMessage:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"displayInboxMessage called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- [self.messageViewController dismissViewControllerAnimated:YES completion:nil];
-
- UAMessageViewController *mvc = [[UAMessageViewController alloc] init];
- mvc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- mvc.modalPresentationStyle = UIModalPresentationFullScreen;
- [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:mvc animated:YES completion:nil];
-
- // Load the message
- [mvc loadMessageForID:[command.arguments firstObject]];
-
- // Store a weak reference to the MessageViewController so we can dismiss it later
- self.messageViewController = mvc;
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)dismissInboxMessage:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"dismissInboxMessage called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- [self.messageViewController dismissViewControllerAnimated:YES completion:nil];
- self.messageViewController = nil;
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)refreshInbox:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"refreshInbox called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- [[UAMessageCenter shared].messageList retrieveMessageListWithSuccessBlock:^{
- completionHandler(CDVCommandStatus_OK, nil);
- } withFailureBlock:^{
- completionHandler(CDVCommandStatus_ERROR, @"Inbox failed to refresh");
- }];
- }];
-}
-
-- (void)getActiveNotifications:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getActiveNotifications called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- if (@available(iOS 10.0, *)) {
- [[UNUserNotificationCenter currentNotificationCenter] getDeliveredNotificationsWithCompletionHandler:^(NSArray * _Nonnull notifications) {
-
- NSMutableArray *result = [NSMutableArray array];
- for(UNNotification *unnotification in notifications) {
- UNNotificationContent *content = unnotification.request.content;
- [result addObject:[UACordovaPushEvent pushEventDataFromNotificationContent:content.userInfo]];
- }
-
- completionHandler(CDVCommandStatus_OK, result);
- }];
- } else {
- completionHandler(CDVCommandStatus_ERROR, @"Only available on iOS 10+");
- }
- }];
-}
-
-- (void)clearNotification:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"clearNotification called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- if (@available(iOS 10.0, *)) {
- NSString *identifier = command.arguments.firstObject;
-
- if (identifier) {
- [[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers:@[identifier]];
- }
-
- completionHandler(CDVCommandStatus_OK, nil);
- }
- }];
-}
-
-- (void)clearNotifications:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"clearNotifications called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- if (@available(iOS 10.0, *)) {
- [[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications];
- }
-
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)editChannelAttributes:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"editChannelAttributes called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
-
- [UAirship.channel editAttributes:^(UAAttributesEditor *editor) {
- [self applyAttributeEdits:[args objectAtIndex:0] editor:editor];
- }];
- }];
-}
-
-- (void)editNamedUserAttributes:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"editNamedUserAttributes called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- [UAirship.contact editAttributes:^(UAAttributesEditor *editor) {
- [self applyAttributeEdits:[args objectAtIndex:0] editor:editor];
- }];
- }];
-}
-
-
-- (BOOL)notifyListener:(NSString *)eventType data:(NSDictionary *)data {
- UA_LTRACE(@"notifyListener called with event type:%@ and data:%@", eventType, data);
-
- if (!self.listenerCallbackID) {
- UA_LTRACE(@"Listener callback unavailable, event %@", eventType);
- return false;
- }
-
- NSMutableDictionary *message = [NSMutableDictionary dictionary];
- [message setValue:eventType forKey:@"eventType"];
- [message setValue:data forKey:@"eventData"];
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:message];
- [result setKeepCallbackAsBool:YES];
-
- [self.commandDelegate sendPluginResult:result callbackId:self.listenerCallbackID];
-
- return true;
-}
-
-- (void)enableFeature:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"enableFeature called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSArray *features = [args firstObject];
- if ([self isValidFeature:features]) {
- [[UAirship shared].privacyManager enableFeatures:[self stringToFeature:features]];
- completionHandler(CDVCommandStatus_OK, nil);
- } else {
- completionHandler(CDVCommandStatus_ERROR, @"Invalid feature, cancelling the action.");
- }
- }];
-}
-
-- (void)disableFeature:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"disableFeature called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSArray *features = [args firstObject];
- if ([self isValidFeature:features]) {
- [[UAirship shared].privacyManager disableFeatures:[self stringToFeature:features]];
- completionHandler(CDVCommandStatus_OK, nil);
- } else {
- completionHandler(CDVCommandStatus_ERROR, @"Invalid feature, cancelling the action.");
- }
- }];
-}
-
-- (void)setEnabledFeatures:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setEnabledFeatures called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSArray *features = [args firstObject];
- if ([self isValidFeature:features]) {
- [UAirship shared].privacyManager.enabledFeatures = [self stringToFeature:features];
- completionHandler(CDVCommandStatus_OK, nil);
- } else {
- completionHandler(CDVCommandStatus_ERROR, @"Invalid feature, cancelling the action.");
- }
- }];
-}
-
-- (void)getEnabledFeatures:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getEnabledFeatures called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- completionHandler(CDVCommandStatus_OK, [self featureToString:[UAirship shared].privacyManager.enabledFeatures]);
- }];
-}
-
-- (void)isFeatureEnabled:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"isFeatureEnabled called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSArray *features = [args firstObject];
- if ([self isValidFeature:features]) {
- completionHandler(CDVCommandStatus_OK, @([[UAirship shared].privacyManager isEnabled:[self stringToFeature:features]]));
- } else {
- completionHandler(CDVCommandStatus_ERROR, @"Invalid feature, cancelling the action.");
- }
- }];
-}
-
-- (void)openPreferenceCenter:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"openPreferenceCenter called with command arguments: %@", command.arguments);
-
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSString *preferenceCenterID = [args firstObject];
- [[UAPreferenceCenter shared] openPreferenceCenter:preferenceCenterID];
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)getPreferenceCenterConfig:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getPreferenceCenterConfig called with command arguments: %@", command.arguments);
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSString *preferenceCenterID = [args firstObject];
- [[UAPreferenceCenter shared] jsonConfigForPreferenceCenterID:preferenceCenterID completionHandler:^(NSDictionary *config) {
- completionHandler(CDVCommandStatus_OK, config);
- }];
- }];
-}
-
-- (void)setUseCustomPreferenceCenterUi:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setUseCustomPreferenceCenterUi called with command arguments: %@", command.arguments);
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSString *preferenceCenterID = [args firstObject];
- BOOL useCustomUI = [[args objectAtIndex:1] boolValue];
- [self.pluginManager setPreferenceCenter:preferenceCenterID useCustomUI:useCustomUI];
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)getCurrentLocale:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"getCurrentLocale called with command arguments: %@", command.arguments);
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSLocale *airshipLocale = [[UAirship shared].localeManager currentLocale];
- completionHandler(CDVCommandStatus_OK, airshipLocale.localeIdentifier);
- }];
-}
-
-- (void)setCurrentLocale:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"setCurrentLocale called with command arguments: %@", command.arguments);
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- NSString *localeIdentifier = [args firstObject];
- [UAirship.shared.localeManager setCurrentLocale:[NSLocale localeWithLocaleIdentifier:localeIdentifier]];
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (void)clearLocale:(CDVInvokedUrlCommand *)command {
- UA_LTRACE(@"clearLocale called with command arguments: %@", command.arguments);
- [self performCallbackWithCommand:command withBlock:^(NSArray *args, UACordovaCompletionHandler completionHandler) {
- [[UAirship shared].localeManager clearLocale];
- completionHandler(CDVCommandStatus_OK, nil);
- }];
-}
-
-- (BOOL)isValidFeature:(NSArray *)features {
- if (!features || [features count] == 0) {
- return NO;
- }
- NSDictionary *authorizedFeatures = [self authorizedFeatures];
-
- for (NSString *feature in features) {
- if (![authorizedFeatures objectForKey:feature]) {
- return NO;
- }
- }
- return YES;
-}
-
-- (UAFeatures)stringToFeature:(NSArray *)features {
- NSDictionary *authorizedFeatures = [self authorizedFeatures];
-
- NSNumber *objectFeature = authorizedFeatures[[features objectAtIndex:0]];
- UAFeatures convertedFeatures = [objectFeature longValue];
-
- if ([features count] > 1) {
- int i;
- for (i = 1; i < [features count]; i++) {
- NSNumber *objectFeature = authorizedFeatures[[features objectAtIndex:i]];
- convertedFeatures |= [objectFeature longValue];
- }
- }
- return convertedFeatures;
-}
-
-- (NSArray *)featureToString:(UAFeatures)features {
- NSMutableArray *convertedFeatures = [[NSMutableArray alloc] init];
-
- NSDictionary *authorizedFeatures = [self authorizedFeatures];
-
- if (features == UAFeaturesAll) {
- [convertedFeatures addObject:@"FEATURE_ALL"];
- } else if (features == UAFeaturesNone) {
- [convertedFeatures addObject:@"FEATURE_NONE"];
- } else {
- for (NSString *feature in authorizedFeatures) {
- NSNumber *objectFeature = authorizedFeatures[feature];
- long longFeature = [objectFeature longValue];
- if ((longFeature & features) && (longFeature != UAFeaturesAll)) {
- [convertedFeatures addObject:feature];
- }
- }
- }
- return convertedFeatures;
-}
-
-- (NSDictionary *)authorizedFeatures {
- NSMutableDictionary *authorizedFeatures = [[NSMutableDictionary alloc] init];
- [authorizedFeatures setValue:@(UAFeaturesNone) forKey:@"FEATURE_NONE"];
- [authorizedFeatures setValue:@(UAFeaturesInAppAutomation) forKey:@"FEATURE_IN_APP_AUTOMATION"];
- [authorizedFeatures setValue:@(UAFeaturesMessageCenter) forKey:@"FEATURE_MESSAGE_CENTER"];
- [authorizedFeatures setValue:@(UAFeaturesPush) forKey:@"FEATURE_PUSH"];
- [authorizedFeatures setValue:@(UAFeaturesChat) forKey:@"FEATURE_CHAT"];
- [authorizedFeatures setValue:@(UAFeaturesAnalytics) forKey:@"FEATURE_ANALYTICS"];
- [authorizedFeatures setValue:@(UAFeaturesTagsAndAttributes) forKey:@"FEATURE_TAGS_AND_ATTRIBUTES"];
- [authorizedFeatures setValue:@(UAFeaturesContacts) forKey:@"FEATURE_CONTACTS"];
- [authorizedFeatures setValue:@(UAFeaturesLocation) forKey:@"FEATURE_LOCATION"];
- [authorizedFeatures setValue:@(UAFeaturesAll) forKey:@"FEATURE_ALL"];
- return authorizedFeatures;
-}
-
-@end
-
diff --git a/urbanairship-cordova/src/ios/events/UACordovaDeepLinkEvent.h b/urbanairship-cordova/src/ios/events/UACordovaDeepLinkEvent.h
deleted file mode 100644
index 48699e9e..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaDeepLinkEvent.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaEvent.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-extern NSString *const EventDeepLink;
-
-/**
- * Deep link event when a new deep link is received.
- */
-@interface UACordovaDeepLinkEvent : NSObject
-
-/**
- * The event type.
- *
- * @return The event type.
- */
-@property (nonatomic, strong, nullable) NSString *type;
-
-/**
- * The event data.
- *
- * @return The event data.
- */
-@property (nonatomic, strong, nullable) NSDictionary *data;
-
-/**
- * Deep link event when a new deep link is received.
- *
- * @param deepLink The deep link url.
- */
-+ (instancetype)eventWithDeepLink:(NSURL *)deepLink;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/urbanairship-cordova/src/ios/events/UACordovaDeepLinkEvent.m b/urbanairship-cordova/src/ios/events/UACordovaDeepLinkEvent.m
deleted file mode 100644
index 60d7bffc..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaDeepLinkEvent.m
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaDeepLinkEvent.h"
-
-NSString *const EventDeepLink = @"urbanairship.deep_link";
-NSString *const DeepLinkKey = @"deepLink";
-
-@implementation UACordovaDeepLinkEvent
-
-+ (instancetype)eventWithDeepLink:(NSURL *)deepLink {
- return [[UACordovaDeepLinkEvent alloc] initWithDeepLink:deepLink];
-}
-
-- (instancetype)initWithDeepLink:(NSURL *)deepLink {
- self = [super init];
- if (self) {
- self.data = @{DeepLinkKey:[deepLink absoluteString]};
- self.type = EventDeepLink;
- }
- return self;
-}
-
-@end
diff --git a/urbanairship-cordova/src/ios/events/UACordovaEvent.h b/urbanairship-cordova/src/ios/events/UACordovaEvent.h
deleted file mode 100644
index 4727765b..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaEvent.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import
-
-NS_ASSUME_NONNULL_BEGIN
-
-/**
- * Interface for Urban Airship Cordova events.
- */
-@protocol UACordovaEvent
-
-/**
- * The event type.
- *
- * @return The event type.
- */
-@property (nonatomic, strong, nullable) NSString *type;
-
-/**
- * The event data.
- *
- * @return The event data.
- */
-@property (nonatomic, strong, nullable) NSDictionary *data;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/urbanairship-cordova/src/ios/events/UACordovaInboxUpdatedEvent.h b/urbanairship-cordova/src/ios/events/UACordovaInboxUpdatedEvent.h
deleted file mode 100644
index 55e32040..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaInboxUpdatedEvent.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaEvent.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-extern NSString *const EventInboxUpdated;
-
-/**
- * Inbox update event.
- */
-@interface UACordovaInboxUpdatedEvent : NSObject
-
-/**
- * The event type.
- *
- * @return The event type.
- */
-@property (nonatomic, strong, nullable) NSString *type;
-
-/**
- * The event data.
- *
- * @return The event data.
- */
-@property (nonatomic, strong, nullable) NSDictionary *data;
-
-/**
- * The default event.
- *
- * @return The default event.
- */
-+ (instancetype)event;
-
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/urbanairship-cordova/src/ios/events/UACordovaInboxUpdatedEvent.m b/urbanairship-cordova/src/ios/events/UACordovaInboxUpdatedEvent.m
deleted file mode 100644
index febcf801..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaInboxUpdatedEvent.m
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaInboxUpdatedEvent.h"
-
-NSString *const EventInboxUpdated = @"urbanairship.inbox_updated";
-
-@implementation UACordovaInboxUpdatedEvent
-
-+ (instancetype)event {
- return [[UACordovaInboxUpdatedEvent alloc] init];
-}
-
-- (instancetype)init {
- self = [super init];
- if (self) {
- self.data = nil;
- self.type = EventInboxUpdated;
- }
- return self;
-}
-
-@end
diff --git a/urbanairship-cordova/src/ios/events/UACordovaNotificationOpenedEvent.h b/urbanairship-cordova/src/ios/events/UACordovaNotificationOpenedEvent.h
deleted file mode 100644
index 84f8918b..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaNotificationOpenedEvent.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaPushEvent.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-extern NSString *const EventNotificationOpened;
-
-/**
- * Notification opened event.
- */
-@interface UACordovaNotificationOpenedEvent : UACordovaPushEvent
-
-/**
- * Notification opened event with notification response.
- *
- * @param content The notification response.
-*/
-+ (instancetype)eventWithNotificationResponse:(UNNotificationResponse *)response;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/urbanairship-cordova/src/ios/events/UACordovaNotificationOpenedEvent.m b/urbanairship-cordova/src/ios/events/UACordovaNotificationOpenedEvent.m
deleted file mode 100644
index 89b9cbcd..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaNotificationOpenedEvent.m
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#if __has_include("AirshipLib.h")
-#import "AirshipLib.h"
-#else
-@import AirshipKit;
-#endif
-
-#import "UACordovaNotificationOpenedEvent.h"
-
-NSString *const EventNotificationOpened = @"urbanairship.notification_opened";
-
-@implementation UACordovaNotificationOpenedEvent
-
-- (instancetype)initWithNotificationResponse:(UNNotificationResponse *)response {
- self = [super init];
-
- if (self) {
- self.type = EventNotificationOpened;
-
- NSDictionary *pushEvent = [[self class] pushEventDataFromNotificationContent:response.notification.request.content.userInfo];
- NSMutableDictionary *data = [NSMutableDictionary dictionaryWithDictionary:pushEvent];
-
- if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) {
- [data setValue:@(YES) forKey:@"isForeground"];
- } else {
- UNNotificationAction *notificationAction = [self notificationActionForCategory:response.notification.request.content.categoryIdentifier
- actionIdentifier:response.actionIdentifier];
-
- BOOL isForeground = notificationAction.options & UNNotificationActionOptionForeground;
- [data setValue:@(isForeground) forKey:@"isForeground"];
- [data setValue:response.actionIdentifier forKey:@"actionID"];
- }
-
- self.data = data;
- }
-
- return self;
-}
-
-+ (instancetype)eventWithNotificationResponse:(UNNotificationResponse *)response {
- return [[self alloc] initWithNotificationResponse:response];
-}
-
-- (UNNotificationAction *)notificationActionForCategory:(NSString *)category actionIdentifier:(NSString *)identifier {
- NSSet *categories = [UAirship push].combinedCategories;
-
- UNNotificationCategory *notificationCategory;
- UNNotificationAction *notificationAction;
-
- for (UNNotificationCategory *possibleCategory in categories) {
- if ([possibleCategory.identifier isEqualToString:category]) {
- notificationCategory = possibleCategory;
- break;
- }
- }
-
- if (!notificationCategory) {
- UA_LERR(@"Unknown notification category identifier %@", category);
- return nil;
- }
-
- NSMutableArray *possibleActions = [NSMutableArray arrayWithArray:notificationCategory.actions];
-
- for (UNNotificationAction *possibleAction in possibleActions) {
- if ([possibleAction.identifier isEqualToString:identifier]) {
- notificationAction = possibleAction;
- break;
- }
- }
-
- if (!notificationAction) {
- UA_LERR(@"Unknown notification action identifier %@", identifier);
- return nil;
- }
-
- return notificationAction;
-}
-
-@end
diff --git a/urbanairship-cordova/src/ios/events/UACordovaNotificationOptInEvent.h b/urbanairship-cordova/src/ios/events/UACordovaNotificationOptInEvent.h
deleted file mode 100644
index 42b212ed..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaNotificationOptInEvent.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#if __has_include("AirshipLib.h")
-#import "AirshipLib.h"
-#else
-@import AirshipKit;
-#endif
-
-#import "UACordovaEvent.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-extern NSString *const EventNotificationOptInStatus;
-
-/**
- * Notification opt-in status event.
- */
-@interface UACordovaNotificationOptInEvent : NSObject
-
-/**
- * The event type.
- *
- * @return The event type.
- */
-@property (nonatomic, strong, nullable) NSString *type;
-
-/**
- * The event data.
- *
- * @return The event data.
- */
-@property (nonatomic, strong, nullable) NSDictionary *data;
-
-/**
- * The opt-in event constructor.
- *
- * @param authorizedSettings The authorized notification settings
- * @return The event opt-in event.
- */
-+ (instancetype)eventWithAuthorizedSettings:(UAAuthorizedNotificationSettings)authorizedSettings;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/urbanairship-cordova/src/ios/events/UACordovaNotificationOptInEvent.m b/urbanairship-cordova/src/ios/events/UACordovaNotificationOptInEvent.m
deleted file mode 100644
index 02a49984..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaNotificationOptInEvent.m
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaNotificationOptInEvent.h"
-
-NSString *const EventNotificationOptInStatus = @"urbanairship.notification_opt_in_status";
-
-NSString *const UACordovaNotificationOptInEventAlertKey = @"alert";
-NSString *const UACordovaNotificationOptInEventBadgeKey = @"badge";
-NSString *const UACordovaNotificationOptInEventSoundKey = @"sound";
-NSString *const UACordovaNotificationOptInEventCarPlayKey = @"carPlay";
-NSString *const UACordovaNotificationOptInEventLockScreenKey = @"lockScreen";
-NSString *const UACordovaNotificationOptInEventNotificationCenterKey = @"notificationCenter";
-
-@implementation UACordovaNotificationOptInEvent
-
-+ (instancetype)eventWithAuthorizedSettings:(UAAuthorizedNotificationSettings)authorizedSettings {
- return [[UACordovaNotificationOptInEvent alloc] initWithAuthorizedSettings:authorizedSettings];
-}
-
-- (instancetype)initWithAuthorizedSettings:(UAAuthorizedNotificationSettings)authorizedSettings {
- self = [super init];
-
- if (self) {
- self.type = EventNotificationOptInStatus;
- self.data = [self eventDataForAuthorizedSettings:authorizedSettings];
- }
-
- return self;
-}
-
-- (NSDictionary *)eventDataForAuthorizedSettings:(UAAuthorizedNotificationSettings)authorizedSettings {
- BOOL optedIn = NO;
-
- BOOL alertBool = NO;
- BOOL badgeBool = NO;
- BOOL soundBool = NO;
- BOOL carPlayBool = NO;
- BOOL lockScreenBool = NO;
- BOOL notificationCenterBool = NO;
-
- if (authorizedSettings & UAAuthorizedNotificationSettingsAlert) {
- alertBool = YES;
- }
-
- if (authorizedSettings & UAAuthorizedNotificationSettingsBadge) {
- badgeBool = YES;
- }
-
- if (authorizedSettings & UAAuthorizedNotificationSettingsSound) {
- soundBool = YES;
- }
-
- if (authorizedSettings & UAAuthorizedNotificationSettingsCarPlay) {
- carPlayBool = YES;
- }
-
- if (authorizedSettings & UAAuthorizedNotificationSettingsLockScreen) {
- lockScreenBool = YES;
- }
-
- if (authorizedSettings & UAAuthorizedNotificationSettingsNotificationCenter) {
- notificationCenterBool = YES;
- }
-
- optedIn = authorizedSettings != UAAuthorizedNotificationSettingsNone;
-
- NSDictionary *eventBody = @{ @"optIn": @(optedIn),
- @"authorizedNotificationSettings" : @{
- UACordovaNotificationOptInEventAlertKey : @(alertBool),
- UACordovaNotificationOptInEventBadgeKey : @(badgeBool),
- UACordovaNotificationOptInEventSoundKey : @(soundBool),
- UACordovaNotificationOptInEventCarPlayKey : @(carPlayBool),
- UACordovaNotificationOptInEventLockScreenKey : @(lockScreenBool),
- UACordovaNotificationOptInEventNotificationCenterKey : @(notificationCenterBool)
- }};
-
- return eventBody;
-}
-
-@end
diff --git a/urbanairship-cordova/src/ios/events/UACordovaPreferenceCenterEvent.h b/urbanairship-cordova/src/ios/events/UACordovaPreferenceCenterEvent.h
deleted file mode 100644
index 61273b3a..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaPreferenceCenterEvent.h
+++ /dev/null
@@ -1,38 +0,0 @@
- /* Copyright Urban Airship and Contributors */
-
- #import "UACordovaEvent.h"
-
- NS_ASSUME_NONNULL_BEGIN
-
- extern NSString *const PreferenceCenterLink;
-
- /**
- * Preference Center event when the open preference center listener is called.
- */
- @interface UACordovaPreferenceCenterEvent : NSObject
-
- /**
- * The event type.
- *
- * @return The event type.
- */
- @property (nonatomic, strong, nullable) NSString *type;
-
- /**
- * The event data.
- *
- * @return The event data.
- */
- @property (nonatomic, strong, nullable) NSDictionary *data;
-
- /**
- * Preference Center event when the open preference center listener is called.
- *
- * @param preferenceCenterId The preference center Id.
- */
- + (instancetype)eventWithPreferenceCenterId:(NSString *)preferenceCenterId;
-
- @end
-
- NS_ASSUME_NONNULL_END
-
diff --git a/urbanairship-cordova/src/ios/events/UACordovaPreferenceCenterEvent.m b/urbanairship-cordova/src/ios/events/UACordovaPreferenceCenterEvent.m
deleted file mode 100644
index 44fdffa1..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaPreferenceCenterEvent.m
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaPreferenceCenterEvent.h"
-
-NSString *const PreferenceCenterLink = @"urbanairship.open_preference_center";
-NSString *const PreferenceCenterKey = @"prefrenceCenter";
-
-@implementation UACordovaPreferenceCenterEvent
-
-+ (instancetype)eventWithPreferenceCenterId:(NSString *)preferenceCenterId {
- return [[UACordovaPreferenceCenterEvent alloc] initWithPreferenceCenterId:preferenceCenterId];
-}
-
-- (instancetype)initWithPreferenceCenterId:(NSString *)preferenceCenterId {
- self = [super init];
- if (self) {
- self.data = @{PreferenceCenterKey:preferenceCenterId};
- self.type = PreferenceCenterLink;
- }
- return self;
-}
-
-@end
\ No newline at end of file
diff --git a/urbanairship-cordova/src/ios/events/UACordovaPushEvent.h b/urbanairship-cordova/src/ios/events/UACordovaPushEvent.h
deleted file mode 100644
index e7b2bbf9..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaPushEvent.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#if __has_include("AirshipLib.h")
-#import "AirshipLib.h"
-#else
-@import AirshipKit;
-#endif
-
-#import "UACordovaEvent.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-extern NSString *const EventPushReceived;
-
-/**
- * Push event.
- */
-@interface UACordovaPushEvent : NSObject
-
-/**
- * The event type.
- *
- * @return The event type.
- */
-@property (nonatomic, strong, nullable) NSString *type;
-
-/**
- * The event data.
- *
- * @return The event data.
- */
-@property (nonatomic, strong, nullable) NSDictionary *data;
-
-/**
- * Push event with notification content.
- *
- * @param userInfo The notification content.
- */
-+ (instancetype)eventWithNotificationContent:(NSDictionary *)userInfo;
-
-/**
- * Helper method for producing sanitized push payloads from notification content.
- *
- * @param userInfo The notification content.
- * @return A push payload dictionary.
- */
-+ (NSDictionary *)pushEventDataFromNotificationContent:(NSDictionary *)userInfo;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/urbanairship-cordova/src/ios/events/UACordovaPushEvent.m b/urbanairship-cordova/src/ios/events/UACordovaPushEvent.m
deleted file mode 100644
index ddc5f21e..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaPushEvent.m
+++ /dev/null
@@ -1,87 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaPushEvent.h"
-
-NSString *const EventPushReceived = @"urbanairship.push";
-
-@implementation UACordovaPushEvent
-
-+ (instancetype)eventWithNotificationContent:(NSDictionary *)userInfo {
- return [[self alloc] initWithNotificationContent:userInfo];
-}
-
-- (instancetype)initWithNotificationContent:(NSDictionary *)userInfo {
- self = [super init];
-
- if (self) {
- self.type = EventPushReceived;
- self.data = [[self class] pushEventDataFromNotificationContent:userInfo];
- }
-
- return self;
-}
-
-+ (NSDictionary *)pushEventDataFromNotificationContent:(NSDictionary *)userInfo {
- if (!userInfo) {
- return @{ @"message": @"", @"extras": @{}};
- }
-
- NSMutableDictionary *info = [NSMutableDictionary dictionaryWithDictionary:userInfo];
-
- // remove the send ID
- if([[info allKeys] containsObject:@"_"]) {
- [info removeObjectForKey:@"_"];
- }
-
- NSMutableDictionary *result = [NSMutableDictionary dictionary];;
-
- // If there is an aps dictionary in the extras, remove it and set it as a top level object
- if([[info allKeys] containsObject:@"aps"]) {
- NSDictionary* aps = info[@"aps"];
-
- if ([[aps allKeys] containsObject:@"alert"]) {
-
- id alert = aps[@"alert"];
- if ([alert isKindOfClass:[NSDictionary class]]) {
- if ([[alert allKeys] containsObject:@"body"]) {
- result[@"message"] = alert[@"body"];
- } else {
- result[@"message"] = @"";
- }
- if ([[alert allKeys] containsObject:@"title"]) {
- [result setValue:alert[@"title"] forKey:@"title"];
- }
- if ([[alert allKeys] containsObject:@"subtitle"]) {
- [result setValue:alert[@"subtitle"] forKey:@"subtitle"];
- }
- } else {
- [result setValue:alert forKey:@"message"];
- }
-
- }
- result[@"aps"] = info[@"aps"];
- [info removeObjectForKey:@"aps"];
- }
-
- NSMutableDictionary *actions = [NSMutableDictionary dictionary];
- for (id key in info.allKeys) {
- if (![key isKindOfClass:[NSString class]]) {
- continue;
- }
-
- if ([UAirship.shared.actionRegistry registryEntryWithName:key]) {
- actions[key] = info[key];
- }
- }
-
- result[@"actions"] = actions;
-
- // Set the remaining info as extras
- result[@"extras"] = info;
-
-
-
- return result;
-}
-
-@end
diff --git a/urbanairship-cordova/src/ios/events/UACordovaRegistrationEvent.h b/urbanairship-cordova/src/ios/events/UACordovaRegistrationEvent.h
deleted file mode 100644
index dce57979..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaRegistrationEvent.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaEvent.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-extern NSString *const EventRegistration;
-
-/**
- * Registration event.
- */
-@interface UACordovaRegistrationEvent : NSObject
-
-/**
- * The event type.
- *
- * @return The event type.
- */
-@property (nonatomic, strong, nullable) NSString *type;
-
-/**
- * The event data.
- *
- * @return The event data.
- */
-@property (nonatomic, strong, nullable) NSDictionary *data;
-
-/**
- * The registration succeeded event constructor.
- *
- * @param channelID The channel ID.
- * @param deviceToken The device token.
- * @return registration event.
- */
-+ (instancetype)registrationSucceededEventWithChannelID:channelID deviceToken:(NSString *)deviceToken;
-
-/**
- * The registration failed event constructor.
- *
- * @return registration event.
-*/
-+ (instancetype)registrationFailedEvent;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/urbanairship-cordova/src/ios/events/UACordovaRegistrationEvent.m b/urbanairship-cordova/src/ios/events/UACordovaRegistrationEvent.m
deleted file mode 100644
index c982e841..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaRegistrationEvent.m
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaRegistrationEvent.h"
-
-NSString *const EventRegistration = @"urbanairship.registration";
-
-@implementation UACordovaRegistrationEvent
-
-+ (instancetype)registrationSucceededEventWithChannelID:channelID deviceToken:(NSString *)deviceToken {
- return [[self alloc] initWithData:[self registrationSucceededData:channelID deviceToken:deviceToken]];
-}
-
-+ (instancetype)registrationFailedEvent {
- return [[self alloc] initWithData:[self registrationFailedData]];
-}
-
-- (instancetype)initWithData:(NSDictionary *)data {
- self = [super init];
- if (self) {
- self.type = EventRegistration;
- self.data = data;
- }
- return self;
-}
-
-+ (NSDictionary *)registrationSucceededData:(NSString *)channelID deviceToken:(NSString *)deviceToken {
- NSDictionary *data;
-
- if (deviceToken) {
- data = @{ @"channelID":channelID, @"deviceToken":deviceToken, @"registrationToken":deviceToken };
- } else {
- data = @{ @"channelID":channelID };
- }
-
- return data;
-}
-
-+ (NSDictionary *)registrationFailedData {
- return @{ @"error": @"Registration failed." };
-}
-
-@end
diff --git a/urbanairship-cordova/src/ios/events/UACordovaShowInboxEvent.h b/urbanairship-cordova/src/ios/events/UACordovaShowInboxEvent.h
deleted file mode 100644
index 4e3eb923..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaShowInboxEvent.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaEvent.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-extern NSString *const EventShowInbox;
-
-/**
- * Show inbox event.
- */
-@interface UACordovaShowInboxEvent : NSObject
-
-/**
- * The event type.
- *
- * @return The event type.
- */
-@property (nonatomic, strong, nullable) NSString *type;
-
-/**
- * The event data.
- *
- * @return The event data.
- */
-@property (nonatomic, strong, nullable) NSDictionary *data;
-
-/**
- * Show default inbox event
- *
- * @return The default inbox event.
- */
-+ (instancetype)event;
-
-/**
- * Show inbox event with message id.
- *
- * @return The inbox event with message identifier data.
- */
-+ (instancetype)eventWithMessageID:(NSString *)identifier;
-
-@end
-
-NS_ASSUME_NONNULL_END
diff --git a/urbanairship-cordova/src/ios/events/UACordovaShowInboxEvent.m b/urbanairship-cordova/src/ios/events/UACordovaShowInboxEvent.m
deleted file mode 100644
index ebdb72a8..00000000
--- a/urbanairship-cordova/src/ios/events/UACordovaShowInboxEvent.m
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-#import "UACordovaShowInboxEvent.h"
-
-NSString *const EventShowInbox = @"urbanairship.show_inbox";
-
-@implementation UACordovaShowInboxEvent
-
-+ (instancetype)event {
- return [[UACordovaShowInboxEvent alloc] initWithMessageID:nil];
-}
-
-+ (instancetype)eventWithMessageID:(NSString *)identifier {
- return [[UACordovaShowInboxEvent alloc] initWithMessageID:identifier];
-}
-
-- (instancetype)init {
- self = [super init];
- if (self) {
- self.type = EventShowInbox;
- self.data = nil;
- }
- return self;
-}
-
-- (instancetype)initWithMessageID:(nullable NSString *)identifier {
- self = [super init];
- if (self) {
- self.type = EventShowInbox;
- self.data = identifier ? @{@"messageId":identifier} : @{};
- }
-
- return self;
-}
-
-@end
diff --git a/urbanairship-cordova/www/UrbanAirship.js b/urbanairship-cordova/www/UrbanAirship.js
deleted file mode 100644
index f36b495b..00000000
--- a/urbanairship-cordova/www/UrbanAirship.js
+++ /dev/null
@@ -1,1406 +0,0 @@
-/* Copyright Urban Airship and Contributors */
-
-var cordova = require("cordova"),
- exec = require("cordova/exec"),
- argscheck = require('cordova/argscheck')
-
-// Argcheck values:
-// * : allow anything,
-// f : function
-// a : array
-// d : date
-// n : number
-// s : string
-// o : object
-// lowercase = required, uppercase = optional
-
-// Helper method to call into the native plugin
-function callNative(success, failure, name, args) {
- args = args || []
- exec(success, failure, "UAirship", name, args)
-}
-
-// Helper method to run an action
-function _runAction(actionName, actionValue, success, failure) {
- var successWrapper = function(result) {
- if (success) {
- success(result.value)
- }
- }
-
- callNative(successWrapper, failure, "runAction", [actionName, actionValue])
-}
-
-/**
- * Constant for Feature NONE.
- */
-const FEATURE_NONE = "FEATURE_NONE"
-/**
- * Constant for InApp Automation Feature.
- */
-const FEATURE_IN_APP_AUTOMATION = "FEATURE_IN_APP_AUTOMATION"
-/**
- * Constant for Message Center Feature.
- */
-const FEATURE_MESSAGE_CENTER = "FEATURE_MESSAGE_CENTER"
-/**
- * Constant for Push Feature.
- */
-const FEATURE_PUSH = "FEATURE_PUSH"
-/**
- * Constant for Chat Feature.
- */
-const FEATURE_CHAT = "FEATURE_CHAT"
-/**
- * Constant for Analytics Feature.
- */
-const FEATURE_ANALYTICS = "FEATURE_ANALYTICS"
-/**
- * Constant for Tags and Attributes Feature.
- */
-const FEATURE_TAGS_AND_ATTRIBUTES = "FEATURE_TAGS_AND_ATTRIBUTES"
-/**
- * Constant for Contacts Feature.
- */
-const FEATURE_CONTACTS = "FEATURE_CONTACTS"
-/**
- * Constant for Location Feature.
- */
-const FEATURE_LOCATION = "FEATURE_LOCATION"
-/**
- * Constant for all Feature.
- */
-const FEATURE_ALL = "FEATURE_ALL"
-
-/**
- * Helper object to edit tag groups.
- *
- * Normally not created directly. Instead use [UrbanAirship.editNamedUserTagGroups]{@link module:UrbanAirship.editNamedUserTagGroups}
- * or [UrbanAirship.editChannelTagGroups]{@link module:UrbanAirship.editChannelTagGroups}.
- *
- * @class TagGroupEditor
- * @param nativeMethod The native method to call on apply.
- */
-function TagGroupEditor(nativeMethod) {
-
- // Store the raw operations and let the SDK combine them
- var operations = []
-
- var editor = {}
-
- /**
- * Adds tags to a tag group.
- * @instance
- * @memberof TagGroupEditor
- * @function addTags
- *
- * @param {string} tagGroup The tag group.
- * @param {array} tags Tags to add.
- * @return {TagGroupEditor} The tag group editor instance.
- */
- editor.addTags = function(tagGroup, tags) {
- argscheck.checkArgs('sa', "TagGroupEditor#addTags", arguments)
- var operation = { "operation": "add", "group": tagGroup, "tags": tags }
- operations.push(operation)
- return editor
- }
-
- /**
- * Removes a tag from the tag group.
- * @instance
- * @memberof TagGroupEditor
- * @function removeTags
- *
- * @param {string} tagGroup The tag group.
- * @param {array} tags Tags to remove.
- * @return {TagGroupEditor} The tag group editor instance.
- */
- editor.removeTags = function(tagGroup, tags) {
- argscheck.checkArgs('sa', "TagGroupEditor#removeTags", arguments)
- var operation = { "operation": "remove", "group": tagGroup, "tags": tags }
- operations.push(operation)
- return editor
- }
-
- /**
- * Applies the tag changes.
- * @instance
- * @memberof TagGroupEditor
- * @function apply
- *
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The failure message.
- * @return {TagGroupEditor} The tag group editor instance.
- */
- editor.apply = function(success, failure) {
- argscheck.checkArgs('FF', "TagGroupEditor#apply", arguments)
- callNative(success, failure, nativeMethod, [operations])
- operations = []
- return editor
- }
-
- return editor
-}
-
-/**
-* Helper object to subscribe/unsubscribe to/from a list.
-*
-* Normally not created directly. Instead use [UrbanAirship.editSubscriptionLists]{@link module:UrbanAirship.editSubscriptionLists}.
-*
-* @class ChannelSubscriptionListEditor
-* @param nativeMethod The native method to call on apply.
-*/
-function ChannelSubscriptionListEditor(nativeMethod) {
-
- // Store the raw operations and let the SDK combine them
- var operations = []
-
- var editor = {}
-
- /**
- * Subscribes to a list.
- * @instance
- * @memberof ChannelSubscriptionListEditor
- * @function subscribe
- *
- * @param {subscriptionListID} subscriptionListID The subscription list identifier.
- * @return {ChannelSubscriptionListEditor} The subscription list editor instance.
- */
- editor.subscribe = function(subscriptionListID) {
- argscheck.checkArgs('s', "ChannelSubscriptionListEditor#subscribe", arguments)
- var operation = { "operation": "subscribe", "listId": subscriptionListID}
- operations.push(operation)
- return editor
- }
-
- /**
- * Unsubscribes from a list.
- * @instance
- * @memberof ChannelSubscriptionListEditor
- * @function unsubscribe
- *
- * @param {subscriptionListID} subscriptionListID The subscription list identifier.
- * @return {ChannelSubscriptionListEditor} The subscription list editor instance.
- */
- editor.unsubscribe = function(subscriptionListID) {
- argscheck.checkArgs('s', "ChannelSubscriptionListEditor#unsubscribe", arguments)
- var operation = { "operation": "unsubscribe", "listId": subscriptionListID}
- operations.push(operation)
- return editor
- }
-
- /**
- * Applies subscription list changes.
- * @instance
- * @memberof ChannelSubscriptionListEditor
- * @function apply
- *
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The failure message.
- * @return {ChannelSubscriptionListEditor} The subscription List editor instance.
- */
- editor.apply = function(success, failure) {
- argscheck.checkArgs('FF', "ChannelSubscriptionListEditor#apply", arguments)
- callNative(success, failure, nativeMethod, [operations])
- operations = []
- return editor
- }
-
- return editor
-}
-
-/**
-* Helper object to subscribe/unsubscribe to/from a list.
-*
-* Normally not created directly. Instead use [UrbanAirship.editContactSubscriptionLists]{@link module:UrbanAirship.editContactSubscriptionLists}.
-*
-* @class ContactSubscriptionListEditor
-* @param nativeMethod The native method to call on apply.
-*/
-function ContactSubscriptionListEditor(nativeMethod) {
-
- // Store the raw operations and let the SDK combine them
- var operations = []
-
- var editor = {}
-
- /**
- * Subscribes to a contact list.
- * @instance
- * @memberof ContactSubscriptionListEditor
- * @function subscribe
- *
- * @param {subscriptionListID} subscriptionListID The subscription list identifier.
- * @param {contactScope} contactScope Defines the channel types that the change applies to.
- * @return {ContactSubscriptionListEditor} The subscription list editor instance.
- */
- editor.subscribe = function(contactSubscriptionListID, contactScope) {
- argscheck.checkArgs('ss', "ContactSubscriptionListEditor#subscribe", arguments)
- var operation = { "operation": "subscribe", "listId": contactSubscriptionListID, "scope": contactScope}
- operations.push(operation)
- return editor
- }
-
- /**
- * Unsubscribes from a contact list.
- * @instance
- * @memberof ContactSubscriptionListEditor
- * @function unsubscribe
- *
- * @param {subscriptionListID} subscriptionListID The subscription list identifier.
- * @param {contactScope} contactScope Defines the channel types that the change applies to.
- * @return {ContactSubscriptionListEditor} The subscription list editor instance.
- */
- editor.unsubscribe = function(contactSubscriptionListID, contactScope) {
- argscheck.checkArgs('ss', "ContactSubscriptionListEditor#unsubscribe", arguments)
- var operation = { "operation": "unsubscribe", "listId": contactSubscriptionListID, "scope": contactScope}
- operations.push(operation)
- return editor
- }
-
- /**
- * Applies subscription list changes.
- * @instance
- * @memberof ContactSubscriptionListEditor
- * @function apply
- *
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The failure message.
- * @return {ContactSubscriptionListEditor} The subscription List editor instance.
- */
- editor.apply = function(success, failure) {
- argscheck.checkArgs('FF', "ContactSubscriptionListEditor#apply", arguments)
- callNative(success, failure, nativeMethod, [operations])
- operations = []
- return editor
- }
-
- return editor
-}
-
-/**
- * Helper object to edit attributes groups.
- *
- * Normally not created directly. Instead use [UrbanAirship.editChannelAttributes]{@link module:UrbanAirship.editChannelAttributes}.
- *
- * @class AttributeEditor
- * @param nativeMethod The native method to call on apply.
- */
-function AttributesEditor(nativeMethod) {
- var operations = []
- var editor = {}
-
- /**
- * Sets an attribute.
- * @instance
- * @memberof AttributesEditor
- * @function setAttribute
- *
- * @param {string} name The attribute name.
- * @param {string|number|Date} value The attribute's value.
- * @return {AttributesEditor} The attribute editor instance.
- */
- editor.setAttribute = function(name, value) {
- argscheck.checkArgs('s*', "AttributesEditor#setAttribute", arguments)
-
- var operation = { "action": "set", "value": value, "key": name }
-
- if (typeof value === "string") {
- operation["type"] = "string"
- } else if (typeof value === "number") {
- operation["type"] = "number"
- } else if (typeof value === "boolean") {
- // No boolean attribute type. Convert value to string.
- operation["type"] = "string"
- operation["value"] = value.toString();
- } else if (value instanceof Date) {
- // JavaScript's date type doesn't pass through the JS to native bridge. Dates are instead serialized as milliseconds since epoch.
- operation["type"] = "date"
- operation["value"] = value.getTime()
- } else {
- throw("Unsupported attribute type: " + typeof value)
- }
-
- operations.push(operation)
-
- return editor
- }
-
- /**
- * Removes an attribute.
- * @instance
- * @memberof AttributesEditor
- * @function removeAttribute
- *
- * @param {string} name The attribute's name.
- * @return {AttributesEditor} The attribute editor instance.
- */
- editor.removeAttribute = function(name) {
- argscheck.checkArgs('s', "AttributesEditor#removeAttribute", arguments)
- var operation = { "action": "remove", "key": name }
- operations.push(operation)
- return editor
- }
-
- /**
- * Applies the attribute changes.
- * @instance
- * @memberof AttributesEditor
- * @function apply
- *
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The failure message.
- * @return {TagGroupEditor} The tag group editor instance.
- */
- editor.apply = function(success, failure) {
- argscheck.checkArgs('FF', "AttributesEditor#apply", arguments)
- callNative(success, failure, nativeMethod, [operations])
- operations = []
- return editor
- }
-
- return editor
-}
-
-function bindDocumentEvent() {
- callNative(function(e) {
- console.log("Firing document event: " + e.eventType)
- cordova.fireDocumentEvent(e.eventType, e.eventData)
- }, null, "registerListener")
-}
-
-document.addEventListener("deviceready", bindDocumentEvent, false)
-
-/**
- * @module UrbanAirship
- */
-module.exports = {
-
- FEATURE_NONE: FEATURE_NONE,
- FEATURE_IN_APP_AUTOMATION: FEATURE_IN_APP_AUTOMATION,
- FEATURE_MESSAGE_CENTER: FEATURE_MESSAGE_CENTER,
- FEATURE_PUSH: FEATURE_PUSH,
- FEATURE_CHAT: FEATURE_CHAT,
- FEATURE_ANALYTICS: FEATURE_ANALYTICS,
- FEATURE_TAGS_AND_ATTRIBUTES: FEATURE_TAGS_AND_ATTRIBUTES,
- FEATURE_CONTACTS: FEATURE_CONTACTS,
- FEATURE_LOCATION: FEATURE_LOCATION,
- FEATURE_ALL: FEATURE_ALL,
-
- /**
- * Event fired when a new deep link is received.
- *
- * @event deep_link
- * @type {object}
- * @param {string} [deepLink] The deep link.
- */
-
- /**
- * Event fired when a channel registration occurs.
- *
- * @event registration
- * @type {object}
- * @param {string} [channelID] The channel ID.
- * @param {string} [registrationToken] The deviceToken on iOS, and the FCM/ADM token on Android.
- * @param {string} [error] Error message if an error occurred.
- */
-
- /**
- * Event fired when the inbox is updated.
- *
- * @event inbox_updated
- */
-
- /**
- * Event fired when the inbox needs to be displayed. This event is only emitted if auto
- * launch message center is disabled.
- *
- * @event show_inbox
- * @type {object}
- * @param {string} [messageId] The optional message ID.
- */
-
- /**
- * Event fired when a push is received.
- *
- * @event push
- * @type {object}
- * @param {string} message The push alert message.
- * @param {string} title The push title.
- * @param {string} subtitle The push subtitle.
- * @param {object} extras Any push extras.
- * @param {object} aps The raw aps dictionary (iOS only)
- * @param {number} [notification_id] The Android notification ID. Deprecated in favor of notificationId.
- * @param {string} [notificationId] The notification ID.
- */
-
- /**
- * Event fired when notification opened.
- *
- * @event notification_opened
- * @type {object}
- * @param {string} message The push alert message.
- * @param {object} extras Any push extras.
- * @param {number} [notification_id] The Android notification ID. Deprecated in favor of notificationId.
- * @param {string} [notificationId] The notification ID.
- * @param {string} [actionID] The ID of the notification action button if available.
- * @param {boolean} isForeground Will always be true if the user taps the main notification. Otherwise its defined by the notification action button.
- */
-
- /**
- * Event fired when the user notification opt-in status changes.
- *
- * @event notification_opt_in_status
- * @type {object}
- * @param {boolean} optIn If the user is opted in or not to user notifications.
- * @param {object} [authorizedNotificationSettings] iOS only. A map of authorized settings.
- * @param {boolean} authorizedNotificationSettings.alert If alerts are authorized.
- * @param {boolean} authorizedNotificationSettings.sound If sounds are authorized.
- * @param {boolean} authorizedNotificationSettings.badge If badges are authorized.
- * @param {boolean} authorizedNotificationSettings.carPlay If car play is authorized.
- * @param {boolean} authorizedNotificationSettings.lockScreen If the lock screen is authorized.
- * @param {boolean} authorizedNotificationSettings.notificationCenter If the notification center is authorized.
- */
-
- /**
- * Re-attaches document event listeners in this webview
- */
- reattach: bindDocumentEvent,
-
- /**
- * Initailizes Urban Airship.
- *
- * The plugin will automatically call takeOff during the next app init in
- * order to properly handle incoming push. If takeOff is called multiple times
- * in a session, or if the config is different than the previous sesssion, the
- * new config will not be used until the next app start.
- *
- * @param {object} config The Urban Airship config.
- * @param {string} config.site Sets the cloud site, must be either EU or US.
- * @param {string} config.messageCenterStyleConfig The message center style config file. By default it's "messageCenterStyleConfig"
- * @param {object} config.development The Urban Airship development config.
- * @param {string} config.development.appKey The development appKey.
- * @param {string} config.development.appSecret The development appSecret.
- * @param {object} config.production The Urban Airship production config.
- * @param {string} config.production.appKey The production appKey.
- * @param {string} config.production.appSecret The production appSecret.
- */
- takeOff: function(config, success, failure) {
- argscheck.checkArgs("*FF", "UAirship.takeOff", arguments);
- callNative(success, failure, "takeOff", [config]);
- },
-
- /**
- * Sets the Android notification config. Values not set will fallback to any values set in the config.xml.
- *
- * @param {object} config The notification config.
- * @param {string} [config.icon] The name of the drawable resource to use as the notification icon.
- * @param {string} [config.largeIcon] The name of the drawable resource to use as the notification large icon.
- * @param {string} [config.accentColor] The notification accent color. Format is #AARRGGBB.
- */
- setAndroidNotificationConfig: function(config, success, failure) {
- argscheck.checkArgs("*FF", "UAirship.setAndroidNotificationConfig", arguments);
- callNative(success, failure, "setAndroidNotificationConfig", [config]);
- },
-
- /**
- * Sets the default behavior when the message center is launched from a push
- * notification. If set to false the message center must be manually launched.
- *
- * @param {boolean} enabled true to automatically launch the default message center, false to disable.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setAutoLaunchDefaultMessageCenter: function(enabled, success, failure) {
- argscheck.checkArgs('*FF', 'UAirship.setAutoLaunchDefaultMessageCenter', arguments)
- callNative(success, failure, "setAutoLaunchDefaultMessageCenter", [!!enabled]);
- },
-
- /**
- * Enables or disables user notifications.
- *
- * @param {boolean} enabled true to enable notifications, false to disable.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setUserNotificationsEnabled: function(enabled, success, failure) {
- argscheck.checkArgs('*FF', 'UAirship.setUserNotificationsEnabled', arguments)
- callNative(success, failure, "setUserNotificationsEnabled", [!!enabled])
- },
-
- /**
- * Checks if user notifications are enabled or not.
- *
- * @param {function(enabled)} success Success callback.
- * @param {boolean} success.enabled Flag indicating if user notifications is enabled or not.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- isUserNotificationsEnabled: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.isUserNotificationsEnabled', arguments)
- callNative(success, failure, "isUserNotificationsEnabled")
- },
-
- /**
- * Enables user notifications.
- *
- * @param {function} success Success callback.
- * @param {boolean} success.enabled Flag indicating if user notifications enablement was authorized or not.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- enableUserNotifications: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.enableUserNotifications', arguments)
- callNative(success, failure, "enableUserNotifications")
- },
-
- /**
- * Checks if app notifications are enabled or not. Its possible to have `userNotificationsEnabled`
- * but app notifications being disabled if the user opted out of notifications.
- *
- * @param {function(enabled)} success Success callback.
- * @param {boolean} success.enabled Flag indicating if app notifications is enabled or not.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- isAppNotificationsEnabled: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.isAppNotificationsEnabled', arguments)
- callNative(success, failure, "isAppNotificationsEnabled")
- },
-
- /**
- * Returns the channel ID.
- *
- * @param {function(ID)} success The function to call on success.
- * @param {string} success.ID The channel ID string
- * @param {failureCallback} [failure] The function to call on failure.
- * @param {string} failure.message The error message.
- */
- getChannelID: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.getChannelID', arguments)
- callNative(success, failure, "getChannelID")
- },
-
- /**
- * Returns the last notification that launched the application.
- *
- * @param {Boolean} clear true to clear the notification.
- * @param {function(push)} success The function to call on success.
- * @param {object} success.push The push message object containing data associated with a push notification.
- * @param {string} success.push.message The push alert message.
- * @param {object} success.push.extras Any push extras.
- * @param {number} [success.push.notification_id] The Android notification ID.
- * @param {failureCallback} [failure] The function to call on failure.
- * @param {string} failure.message The error message.
- */
- getLaunchNotification: function(clear, success, failure) {
- argscheck.checkArgs('*fF', 'UAirship.getLaunchNotification', arguments)
- callNative(success, failure, "getLaunchNotification", [!!clear])
- },
-
- /**
- * Returns the last received deep link.
- *
- * @param {Boolean} clear true to clear the deep link.
- * @param {function(push)} success The function to call on success.
- * @param {string} success.deepLink The deep link.
- * @param {failureCallback} [failure] The function to call on failure.
- * @param {string} failure.message The error message.
- */
- getDeepLink: function(clear, success, failure) {
- argscheck.checkArgs('*fF', 'UAirship.getDeepLink', arguments)
- callNative(success, failure, "getDeepLink", [!!clear])
- },
-
- /**
- * Returns the tags as an array.
- *
- * @param {function(tags)} success The function to call on success.
- * @param {array} success.tags The tags as an array.
- * @param {failureCallback} [failure] The function to call on failure.
- * @param {string} failure.message The error message.
- */
- getTags: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.getTags', arguments);
- callNative(success, failure, "getTags")
- },
-
- /**
- * Sets the tags.
- *
- * @param {Array} tags an array of strings.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setTags: function(tags, success, failure) {
- argscheck.checkArgs('aFF', 'UAirship.setTags', arguments);
- callNative(success, failure, "setTags", [tags])
- },
-
- /**
- * Returns the alias.
- *
- * @deprecated Deprecated since 6.7.0 - to be removed in a future version of the plugin - please use getNamedUser
- *
- * @param {function(currentAlias)} success The function to call on success.
- * @param {string} success.currentAlias The alias as a string.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- getAlias: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.getAlias', arguments)
- callNative(success, failure, "getAlias")
- },
-
- /**
- * Sets the alias.
- *
- * @deprecated Deprecated since 6.7.0 - to be removed in a future version of the plugin - please use setNamedUser
- *
- * @param {String} alias string
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setAlias: function(alias, success, failure) {
- argscheck.checkArgs('sFF', 'UAirship.setAlias', arguments)
- callNative(success, failure, "setAlias", [alias])
- },
-
- /**
- * Checks if quiet time is enabled or not.
- *
- * @param {function(enabled)} success Success callback.
- * @param {boolean} success.enabled Flag indicating if quiet time is enabled or not.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- isQuietTimeEnabled: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.isQuietTimeEnabled', arguments)
- callNative(success, failure, "isQuietTimeEnabled")
- },
-
- /**
- * Enables or disables quiet time.
- *
- * @param {Boolean} enabled true to enable quiet time, false to disable.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setQuietTimeEnabled: function(enabled, success, failure) {
- argscheck.checkArgs('*FF', 'UAirship.setQuietTimeEnabled', arguments)
- callNative(success, failure, "setQuietTimeEnabled", [!!enabled])
- },
-
- /**
- * Checks if the device is currently in quiet time.
- *
- * @param {function(inQuietTime)} success Success callback.
- * @param {boolean} success.inQuietTime Flag indicating if quiet time is currently in effect.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- isInQuietTime: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.isInQuietTime', arguments)
- callNative(success, failure, "isInQuietTime")
- },
-
- /**
- * Returns the quiet time as an object with the following:
- * "startHour": Number,
- * "startMinute": Number,
- * "endHour": Number,
- * "endMinute": Number
- *
- * @param {function(quietTime)} success The function to call on success.
- * @param {object} success.quietTime The quietTime object represents a timespan during
- * which notifications should be silenced.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- getQuietTime: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.getQuietTime', arguments)
- callNative(success, failure, "getQuietTime")
- },
-
- /**
- * Sets the quiet time.
- *
- * @param {Number} startHour for quiet time.
- * @param {Number} startMinute for quiet time.
- * @param {Number} endHour for quiet time.
- * @param {Number} endMinute for quiet time.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setQuietTime: function(startHour, startMinute, endHour, endMinute, success, failure) {
- argscheck.checkArgs('nnnnFF', 'UAirship.setQuietTime', arguments)
- callNative(success, failure, "setQuietTime", [startHour, startMinute, endHour, endMinute])
- },
-
- /**
- * Enables or disables analytics.
- *
- * Disabling analytics will delete any locally stored events
- * and prevent any events from uploading. Features that depend on analytics being
- * enabled may not work properly if it's disabled (reports, region triggers,
- * location segmentation, push to local time).
- *
- * @param {Boolean} enabled true to enable analytics, false to disable.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setAnalyticsEnabled: function(enabled, success, failure) {
- argscheck.checkArgs('*FF', 'UAirship.setAnalyticsEnabled', arguments)
- callNative(success, failure, "setAnalyticsEnabled", [!!enabled])
- },
-
- /**
- * Checks if analytics is enabled or not.
- *
- * @param {function(enabled)} success Success callback.
- * @param {boolean} success.enabled Flag indicating if analytics is enabled or not.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- isAnalyticsEnabled: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.isAnalyticsEnabled', arguments)
- callNative(success, failure, "isAnalyticsEnabled")
- },
-
- /**
- * Returns the named user ID.
- *
- * @param {function(namedUser)} success The function to call on success.
- * @param {string} success.namedUser The named user ID as a string.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- getNamedUser: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.getNamedUser', arguments)
- callNative(success, failure, "getNamedUser")
- },
-
- /**
- * Sets the named user ID.
- *
- * @param {String} namedUser identifier string.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setNamedUser: function(namedUser, success, failure) {
- argscheck.checkArgs('SFF', 'UAirship.setNamedUser', arguments)
- callNative(success, failure, "setNamedUser", [namedUser])
- },
-
- /**
- * Runs an Urban Airship action.
- *
- * @param {String} actionName action as a string.
- * @param {*} actionValue
- * @param {function(result)} [success] The function to call on success.
- * @param {object} success.result The result's value.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- runAction: function(actionName, actionValue, success, failure) {
- argscheck.checkArgs('s*FF', 'UAirship.runAction', arguments)
- _runAction(actionName, actionValue, success, failure)
- },
-
- /**
- * Creates an editor to modify the named user tag groups.
- *
- * @return {TagGroupEditor} A tag group editor instance.
- */
- editNamedUserTagGroups: function() {
- return new TagGroupEditor('editNamedUserTagGroups')
- },
-
- /**
- * Creates an editor to modify the channel tag groups.
- *
- * @return {TagGroupEditor} A tag group editor instance.
- */
- editChannelTagGroups: function() {
- return new TagGroupEditor('editChannelTagGroups')
- },
-
- /**
- * Creates an editor to modify the channel attributes.
- *
- * @return {AttributesEditor} An attributes editor instance.
- */
- editChannelAttributes: function() {
- return new AttributesEditor('editChannelAttributes')
- },
-
- /**
- * Creates an editor to modify the channel subscription lists.
- *
- * @return {ChannelSubscriptionListEditor} A subscription list editor instance.
- */
- editChannelSubscriptionLists: function() {
- return new ChannelSubscriptionListEditor('editChannelSubscriptionLists')
- },
-
- /**
- * Creates an editor to modify the contact subscription lists.
- *
- * @return {ContacttSubscriptionListEditor} A subscription list editor instance.
- */
- editContactSubscriptionLists: function() {
- return new ContactSubscriptionListEditor('editContactSubscriptionLists')
- },
-
- /**
- * Creates an editor to modify the named user attributes.
- *
- * @return {AttributesEditor} An attributes editor instance.
- */
- editNamedUserAttributes: function() {
- return new AttributesEditor('editNamedUserAttributes')
- },
-
- /**
- * Sets an associated identifier for the Connect data stream.
- *
- * @param {string} Custom key for identifier.
- * @param {string} The identifier value.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setAssociatedIdentifier: function(key, identifier, success, failure) {
- argscheck.checkArgs('ssFF', 'UAirship.setAssociatedIdentifier', arguments)
- callNative(success, failure, "setAssociatedIdentifier", [key, identifier])
- },
-
- /**
- * Displays the message center.
- *
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- displayMessageCenter: function(success, failure) {
- argscheck.checkArgs('FF', 'UAirship.displayMessageCenter', arguments)
- callNative(success, failure, "displayMessageCenter")
- },
-
- /**
- * Dismiss the message center.
- *
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- dismissMessageCenter: function(success, failure) {
- argscheck.checkArgs('FF', 'UAirship.dismissMessageCenter', arguments)
- callNative(success, failure, "dismissMessageCenter")
- },
-
- /**
- * Dismiss the inbox message.
- *
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- dismissInboxMessage: function(success, failure) {
- argscheck.checkArgs('FF', 'UAirship.dismissInboxMessage', arguments)
- callNative(success, failure, "dismissInboxMessage")
- },
-
- /**
- * Gets the array of inbox messages. Each message will have the following properties:
- * "id": string - The messages ID. Needed to display, mark as read, or delete the message.
- * "title": string - The message title.
- * "sentDate": number - The message sent date in milliseconds.
- * "listIconUrl": string, optional - The icon url for the message.
- * "isRead": boolean - The unread/read status of the message.
- * "extras": object - String to String map of any message extras.
- *
- * @param {function(messages)} success The function to call on success.
- * @param {array} success.messages The array of inbox messages.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- getInboxMessages: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.getInboxMessages', arguments)
- callNative(success, failure, "getInboxMessages")
- },
-
- /**
- * Marks an inbox message read.
- *
- * @param {String} messageId The ID of the message to mark as read.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- markInboxMessageRead: function(messageId, success, failure) {
- argscheck.checkArgs('sFF', 'UAirship.markInboxMessageRead', arguments)
- callNative(success, failure, 'markInboxMessageRead', [messageId])
- },
-
- /**
- * Deletes an inbox message.
- *
- * @param {String} messageId The ID of the message to delete.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- deleteInboxMessage: function(messageId, success, failure) {
- argscheck.checkArgs('sFF', 'UAirship.deleteInboxMessage', arguments)
- callNative(success, failure, 'deleteInboxMessage', [messageId])
- },
-
- /**
- * Displays the inbox message using a full screen view.
- *
- * @param {String} messageId The ID of the message to display.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- displayInboxMessage: function(messageId, success, failure) {
- argscheck.checkArgs('sFF', 'UAirship.displayInboxMessage', arguments)
- callNative(success, failure, 'displayInboxMessage', [messageId])
- },
-
- /**
- * Forces the inbox to refresh. This is normally not needed as the inbox
- * will automatically refresh on foreground or when a push arrives thats
- * associated with a message, but it can be useful when providing a refresh
- * button for the message listing.
- *
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- refreshInbox: function(success, failure) {
- argscheck.checkArgs('FF', 'UAirship.refreshInbox', arguments)
- callNative(success, failure, 'refreshInbox')
- },
-
- /**
- * Clears a notification by identifier.
- *
- * @param {string} identifier The notification identifier.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- */
- clearNotification: function(identifier, success, failure) {
- argscheck.checkArgs('sFF', 'UAirship.clearNotification', arguments)
- callNative(success, failure, "clearNotification", [identifier])
- },
-
- /**
- * Clears all notifications posted by the application.
- *
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- clearNotifications: function(success, failure) {
- argscheck.checkArgs('FF', 'UAirship.clearNotifications', arguments)
- callNative(success, failure, "clearNotifications")
- },
-
- /**
- * Gets currently active notifications.
- *
- * Note: On Android this functionality is only supported on Android M or higher.
- *
- * @param {function(messages)} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- */
- getActiveNotifications: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.getActiveNotifications', arguments)
- callNative(success, failure, "getActiveNotifications")
- },
-
- // iOS only
-
- /**
- * Enables or disables auto badge. Defaults to `NO`.
- *
- * @param {Boolean} enabled true to enable auto badge, false to disable.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setAutobadgeEnabled: function(enabled, success, failure) {
- argscheck.checkArgs('*FF', 'UAirship.setAutobadgeEnabled', arguments)
- callNative(success, failure, "setAutobadgeEnabled", [!!enabled])
- },
-
- /**
- * Sets the badge number.
- *
- * @param {Number} number specified badge to set.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setBadgeNumber: function(number, success, failure) {
- argscheck.checkArgs('nFF', 'UAirship.setBadgeNumber', arguments)
- callNative(success, failure, "setBadgeNumber", [number])
- },
-
- /**
- * Returns the current badge number.
- *
- * @param {function(badgeNumber)} success The function to call on success.
- * @param {int} success.badgeNumber The current application badge number.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- getBadgeNumber: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.getBadgeNumber', arguments)
- callNative(success, failure, "getBadgeNumber")
- },
-
- /**
- * Clears the badge.
- *
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- resetBadge: function(success, failure) {
- argscheck.checkArgs('FF', 'UAirship.resetBadge', arguments)
- callNative(success, failure, "resetBadge")
- },
-
- /**
- * Sets the iOS notification types. Specify the combination of
- * badges, sound and alerts that are desired.
- *
- * @param {notificationType} types specified notification types.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setNotificationTypes: function(types, success, failure) {
- argscheck.checkArgs('nFF', 'UAirship.setNotificationTypes', arguments)
- callNative(success, failure, "setNotificationTypes", [types])
- },
-
- /**
- * Sets the iOS presentation options. Specify the combination of
- * badges, sound and alerts that are desired.
- *
- * @param {presentationOptions} types specified presentation options.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setPresentationOptions: function(options, success, failure) {
- argscheck.checkArgs('nFF', 'UAirship.setPresentationOptions', arguments)
- callNative(success, failure, "setPresentationOptions", [options])
- },
-
- /**
- * Enables/Disables foreground notifications display on Android.
- *
- * @param {Boolean} enabled true to enable foreground notifications, false to disable.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setAndroidForegroundNotificationsEnabled: function(enabled, success, failure) {
- argscheck.checkArgs('*FF', 'UAirship.setAndroidForegroundNotificationsEnabled', arguments)
- callNative(success, failure, "setAndroidForegroundNotificationsEnabled", [!!enabled])
- },
-
- /**
- * Enum for notification types.
- * @readonly
- * @enum {number}
- */
- notificationType: {
- none: 0,
- badge: 1,
- sound: 2,
- alert: 4
- },
-
- /**
- * Enum for presentation options.
- * @readonly
- * @enum {number}
- */
- presentationOptions: {
- none: 0,
- badge: 1,
- sound: 2,
- alert: 4
- },
-
- // Android only
-
- /**
- * Checks if notification sound is enabled or not.
- *
- * @param {function(enabled)} success Success callback.
- * @param {boolean} success.enabled Flag indicating if sound is enabled or not.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- isSoundEnabled: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.isSoundEnabled', arguments)
- callNative(success, failure, "isSoundEnabled")
- },
-
- /**
- * Enables or disables notification sound.
- *
- * @param {Boolean} enabled true to enable sound, false to disable.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setSoundEnabled: function(enabled, success, failure) {
- argscheck.checkArgs('*FF', 'UAirship.setSoundEnabled', arguments)
- callNative(success, failure, "setSoundEnabled", [!!enabled])
- },
-
- /**
- * Checks if notification vibration is enabled or not.
- *
- * @param {function(enabled)} success Success callback.
- * @param {boolean} success.enabled Flag indicating if vibration is enabled or not.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- isVibrateEnabled: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.isVibrateEnabled', arguments)
- callNative(success, failure, "isVibrateEnabled")
- },
-
- /**
- * Enables or disables notification vibration.
- *
- * @param {Boolean} enabled true to enable vibration, false to disable.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setVibrateEnabled: function(enabled, success, failure) {
- argscheck.checkArgs('*FF', 'UAirship.setVibrateEnabled', arguments)
- callNative(success, failure, "setVibrateEnabled", [!!enabled])
- },
-
- /**
- * Adds a custom event.
- *
- * @param {object} event The custom event object.
- * @param {string} event.name The event's name.
- * @param {number} [event.value] The event's value.
- * @param {string} [event.transactionId] The event's transaction ID.
- * @param {object} [event.properties] The event's properties. Only numbers, booleans, strings, and array of strings are supported.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- addCustomEvent: function(event, success, failure) {
- argscheck.checkArgs('oFF', 'UAirship.addCustomEvent', arguments)
-
- var actionArg = {
- event_name: event.name,
- event_value: event.value,
- transaction_id: event.transactionId,
- properties: event.properties
- }
-
- _runAction("add_custom_event_action", actionArg, success, failure)
- },
-
- /**
- * Initiates screen tracking for a specific app screen, must be called once per tracked screen.
- *
- * @param {string} screen The screen's string identifier.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- trackScreen: function(screen, success, failure) {
- argscheck.checkArgs('sFF', 'UAirship.trackScreen', arguments)
- callNative(success, failure, "trackScreen", [screen])
- },
-
- /**
- * Enables features, adding them to the set of currently enabled features.
- *
- * @param {array} features The features to enable.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- enableFeature: function(features, success, failure) {
- argscheck.checkArgs('aFF', 'UAirship.enableFeature', arguments)
- callNative(success, failure, "enableFeature", [features])
- },
-
- /**
- * Disables features, removing them from the set of currently enabled features.
- *
- * @param {array} features The features to disable.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- disableFeature: function(features, success, failure) {
- argscheck.checkArgs('aFF', 'UAirship.disableFeature', arguments)
- callNative(success, failure, "disableFeature", [features])
- },
-
- /**
- * Sets the current enabled features, replacing any currently enabled features with the given set.
- *
- * @param {array} features The features to set as enabled.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- setEnabledFeatures: function(features, success, failure) {
- argscheck.checkArgs('aFF', 'UAirship.setEnabledFeatures', arguments)
- callNative(success, failure, "setEnabledFeatures", [features])
- },
-
- /**
- * Gets the current enabled features.
- *
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- getEnabledFeatures: function(success, failure) {
- argscheck.checkArgs('FF', 'UAirship.getEnabledFeatures', arguments)
- callNative(success, failure, "getEnabledFeatures")
- },
-
- /**
- * Checks if all of the given features are enabled.
- *
- * @param {array} features The features to check.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- isFeatureEnabled: function(features, success, failure) {
- argscheck.checkArgs('aFF', 'UAirship.isFeatureEnabled', arguments)
- callNative(success, failure, "isFeatureEnabled", [features])
- },
-
- /**
- * Opens the Preference Center with the given preferenceCenterId.
- *
- * @param {string} preferenceCenterId The preference center ID.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- openPreferenceCenter: function(preferenceCenterId, success, failure) {
- argscheck.checkArgs('sFF', 'UAirship.openPreferenceCenter', arguments)
- callNative(success, failure, "openPreferenceCenter", [preferenceCenterId])
- },
-
- /**
- * Returns the configuration of the Preference Center with the given ID trough a callback method.
- *
- * @param {string} preferenceCenterId The preference center ID.
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- getPreferenceCenterConfig: function(preferenceCenterId, success, failure) {
- argscheck.checkArgs('sFF', 'UAirship.getPreferenceCenterConfig', arguments)
- callNative(success, failure, "getPreferenceCenterConfig", [preferenceCenterId])
- },
-
- /**
- * Returns the current set of subscription lists for the current channel,
- * optionally applying pending subscription list changes that will be applied during the next channel update.
- * An empty set indicates that this contact is not subscribed to any lists.
- *
- * @param {function} [success] Success callback.
- * @param {string} failure.message The error message.
- */
- getChannelSubscriptionLists: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.getChannelSubscriptionLists', arguments)
- callNative(success, failure, "getChannelSubscriptionLists")
- },
-
- /**
- * Returns the current set of subscription lists for the current contact,
- * optionally applying pending subscription list changes that will be applied during the next contact update.
- * An empty set indicates that this contact is not subscribed to any lists.
- *
- * @param {function} [success] Success callback.
- * @param {string} failure.message The error message.
- */
- getContactSubscriptionLists: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.getContactSubscriptionLists', arguments)
- callNative(success, failure, "getContactSubscriptionLists")
- },
-
- /**
- * Sets the use custom preference center.
- *
- * @param {string} preferenceCenterId The preference center ID.
- * @param {boolean} useCustomUi The preference center use custom UI.
- */
- setUseCustomPreferenceCenterUi: function(preferenceCenterId, useCustomUi, success, failure) {
- argscheck.checkArgs("s*FF", "UAirship.setUseCustomPreferenceCenterUi", arguments)
- callNative(success, failure, "setUseCustomPreferenceCenterUi", [preferenceCenterId, useCustomUi])
- },
-
- /**
- * Overriding the locale.
- *
- * @param {string} localeIdentifier The locale identifier.
- */
- setCurrentLocale: function(localeIdentifier, success, failure) {
- argscheck.checkArgs("sFF", "UAirship.setCurrentLocale", arguments)
- callNative(success, failure, "setCurrentLocale", [localeIdentifier])
- },
-
- /**
- * Getting the locale currently used by Airship.
- *
- * @param {function} [success] Success callback.
- * @param {string} failure.message The error message.
- */
- getCurrentLocale: function(success, failure) {
- argscheck.checkArgs('fF', 'UAirship.getCurrentLocale', arguments)
- callNative(success, failure, "getCurrentLocale")
- },
-
- /**
- * Resets the current locale.
- *
- * @param {function} [success] Success callback.
- * @param {function(message)} [failure] Failure callback.
- * @param {string} failure.message The error message.
- */
- clearLocale: function(success, failure) {
- argscheck.checkArgs('FF', 'UAirship.clearLocale', arguments)
- callNative(success, failure, "clearLocale")
- }
-
-}