diff --git a/CHANGELOG.md b/CHANGELOG.md index d47f88c..cca51a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Change Log ========== +### Version 6.3.1 +* Added support for logging the SDK state to the native platform logging system (Android: Logcat, iOS: Console). +* Added documentation for setting up push for iOS. + ### Version 6.3.0 * Updated to the 6.3.x versions of the Android and iOS Marketing Cloud SDK. diff --git a/README.md b/README.md index 8dccc57..9dccc15 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Salesforce Marketing Cloud Cordova Plugin -Use this plugin to implement the Marketing Cloud MobilePush SDK for your [iOS](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/) and [Android](http://salesforce-marketingcloud.github.io/JB4A-SDK-Android/) applications. +Use this plugin to implement the Marketing Cloud MobilePush SDK for your [iOS](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/) and [Android](http://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/) applications. ## Release Notes @@ -53,6 +53,10 @@ To enable push support for the Android platform you will need to include the goo ``` +#### 4. Enable iOS Push + +Follow [these instructions](./ios_push.md) to enable push for iOS. + ## API Reference @@ -74,6 +78,7 @@ To enable push support for the Android platform you will need to include the goo * [.disableVerboseLogging([successCallback], [errorCallback])](#module_MCCordovaPlugin.disableVerboseLogging) * [.setOnNotificationOpenedListener(notificationOpenedListener)](#module_MCCordovaPlugin.setOnNotificationOpenedListener) * [.setOnUrlActionListener(urlActionListener)](#module_MCCordovaPlugin.setOnUrlActionListener) + * [.logSdkState([successCallback], [errorCallback])](#module_MCCordovaPlugin.logSdkState) * _inner_ * [~notificationOpenedCallback](#module_MCCordovaPlugin..notificationOpenedCallback) : function * [~urlActionCallback](#module_MCCordovaPlugin..urlActionCallback) : function @@ -93,7 +98,7 @@ SDK. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#isPushEnabled()) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#isPushEnabled()) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_pushEnabled) @@ -111,7 +116,7 @@ Enables push messaging in the native Marketing Cloud SDK. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#enablePush()) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#enablePush()) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_setPushEnabled:) @@ -128,7 +133,7 @@ Disables push messaging in the native Marketing Cloud SDK. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#disablePush()) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#disablePush()) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_setPushEnabled:) @@ -146,7 +151,7 @@ the device. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#getPushToken()) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#getPushToken()) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_deviceToken) @@ -164,14 +169,14 @@ Returns the maps of attributes set in the registration. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.html#getAttributes()) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.html#getAttributes()) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_attributes) | Param | Type | Description | | --- | --- | --- | | successCallback | function | | -| successCallback.attributes | Object.<string, string> | The key/value map of attributes set in the registration. | +| successCallback.attributes | [ 'Object' ].<string, string> | The key/value map of attributes set in the registration. | | [errorCallback] | function | | @@ -182,7 +187,7 @@ Sets the value of an attribute in the registration. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#setAttribute(java.lang.String,%20java.lang.String)) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#setAttribute(java.lang.String,%20java.lang.String)) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_setAttributeNamed:value:) @@ -202,7 +207,7 @@ Clears the value of an attribute in the registration. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#clearAttribute(java.lang.String)) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#clearAttribute(java.lang.String)) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_clearAttributeNamed:) @@ -219,7 +224,7 @@ Clears the value of an attribute in the registration. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#addTag(java.lang.String)) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#addTag(java.lang.String)) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_addTag:) @@ -236,7 +241,7 @@ Clears the value of an attribute in the registration. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#removeTag(java.lang.String)) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#removeTag(java.lang.String)) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_removeTag:) @@ -255,14 +260,14 @@ Returns the tags currently set on the device. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.html#getTags()) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.html#getTags()) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_tags) | Param | Type | Description | | --- | --- | --- | | successCallback | function | | -| successCallback.tags | Array.<string> | The array of tags currently set in the native SDK. | +| successCallback.tags | [ 'Array' ].<string> | The array of tags currently set in the native SDK. | | [errorCallback] | function | | @@ -273,7 +278,7 @@ Sets the contact key for the device's user. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#setContactKey(java.lang.String)) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#setContactKey(java.lang.String)) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_setContactKey:) @@ -292,7 +297,7 @@ Returns the contact key currently set on the device. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.html#getContactKey()) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.html#getContactKey()) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_contactKey) @@ -310,7 +315,7 @@ Enables verbose logging within the native Marketing Cloud SDK. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/MarketingCloudSdk.html#setLogLevel(int)) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/MarketingCloudSdk.html#setLogLevel(int)) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_setDebugLoggingEnabled:) @@ -327,7 +332,7 @@ Disables verbose logging within the native Marketing Cloud SDK. **Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) **See** -- [Android Docs](https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/MarketingCloudSdk.html#setLogLevel(int)) +- [Android Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/MarketingCloudSdk.html#setLogLevel(int)) - [iOS Docs](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_setDebugLoggingEnabled:) @@ -358,6 +363,20 @@ Disables verbose logging within the native Marketing Cloud SDK. | urlActionListener | function | | urlActionListener.event | MCCordovaPlugin~urlActionCallback | + + +### MCCordovaPlugin.logSdkState([successCallback], [errorCallback]) +Instructs the native SDK to log the SDK state to the native logging system (Logcat for +Android and Xcode/Console.app for iOS). This content can help diagnose most issues within +the SDK and will be requested by the Marketing Cloud support team. + +**Kind**: static method of [MCCordovaPlugin](#module_MCCordovaPlugin) + +| Param | Type | +| --- | --- | +| [successCallback] | function | +| [errorCallback] | function | + ### MCCordovaPlugin~notificationOpenedCallback : function diff --git a/ios_push.md b/ios_push.md new file mode 100644 index 0000000..b41e196 --- /dev/null +++ b/ios_push.md @@ -0,0 +1,175 @@ +# Enable Push for iOS + +> These steps will need to be done each time the platform is added to your Cordova application. + +1. Enable push notifications in your target’s Capabilities settings in xCode. + + ![push enablement](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/assets/SDKConfigure8.png) + +2. **Enable Rich Notifications:** Rich notifications include images, videos, titles and subtitles from the MobilePush app, and mutable content. Mutable content can include personalization in the title, subtitle, or body of your message. + 1. In Xcode, click **File** + 2. Click **New** + 3. Click **Target** + 4. Select **Notification Service Extension** + 5. Name and save the new extension + + This service extension checks for a `"_mediaUrl"` element in request.content.userInfo. If found, the extension attempts to download the media from the URL , creates a thumbnail-size version, and then adds the attachment. The service extension also checks for a `"_mediaAlt"` element in request.content.userInfo. If found, the service extension uses the element for the body text if there are any problems downloading or creating the media attachment. + + A service extension can timeout when it is unable to download. In this code sample, the service extension delivers the original content with the body text changed to the value in `"_mediaAlt"`. + + ```objc + #import + #import "NotificationService.h" + + @interface NotificationService () + + @property(nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver); + @property(nonatomic, strong) UNMutableNotificationContent *modifiedNotificationContent; + + @end + + @implementation NotificationService + + - (UNNotificationAttachment *)createMediaAttachment:(NSURL *)localMediaUrl { + // options: specify what cropping rectangle of the media to use for a thumbnail + // whether the thumbnail is hidden or not + UNNotificationAttachment *mediaAttachment = [UNNotificationAttachment + attachmentWithIdentifier:@"attachmentIdentifier" + URL:localMediaUrl + options:@{ + UNNotificationAttachmentOptionsThumbnailClippingRectKey : + (NSDictionary *)CFBridgingRelease( + CGRectCreateDictionaryRepresentation(CGRectZero)), + UNNotificationAttachmentOptionsThumbnailHiddenKey : @NO + } + error:nil]; + return mediaAttachment; + } + + - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request + withContentHandler:(void (^)(UNNotificationContent *_Nonnull))contentHandler { + // save the completion handler we will call back later + self.contentHandler = contentHandler; + + // make a copy of the notification so we can change it + self.modifiedNotificationContent = [request.content mutableCopy]; + + // alternative text to display if there are any issues loading the media URL + NSString *mediaAltText = request.content.userInfo[@"_mediaAlt"]; + + // does the payload contains a remote URL to download or a local URL? + NSString *mediaUrlString = request.content.userInfo[@"_mediaUrl"]; + NSURL *mediaUrl = [NSURL URLWithString:mediaUrlString]; + + // if we have a URL, try to download media (i.e., + // https://media.giphy.com/media/3oz8xJBbCpzG9byZmU/giphy.gif) + if (mediaUrl != nil) { + // create a session to handle downloading of the URL + NSURLSession *session = [NSURLSession + sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; + + // start a download task to handle the download of the media + __weak __typeof__(self) weakSelf = self; + [[session + downloadTaskWithURL:mediaUrl + completionHandler:^(NSURL *_Nullable location, NSURLResponse *_Nullable response, + NSError *_Nullable error) { + BOOL useAlternateText = YES; + + // if the download succeeded, save it locally and then make an attachment + if (error == nil) { + if (200 <= ((NSHTTPURLResponse *)response).statusCode && + ((NSHTTPURLResponse *)response).statusCode <= 299) { + // download was successful, attempt save the media file + NSURL *localMediaUrl = [NSURL + fileURLWithPath:[location.path + stringByAppendingString:mediaUrl + .lastPathComponent]]; + + // remove any existing file with the same name + [[NSFileManager defaultManager] removeItemAtURL:localMediaUrl error:nil]; + + // move the downloaded file from the temporary location to a new file + if ([[NSFileManager defaultManager] moveItemAtURL:location + toURL:localMediaUrl + error:nil] == YES) { + // create an attachment with the new file + UNNotificationAttachment *mediaAttachment = + [weakSelf createMediaAttachment:localMediaUrl]; + + // if no problems creating the attachment, we can use it + if (mediaAttachment != nil) { + // set the media to display in the notification + weakSelf.modifiedNotificationContent.attachments = + @[ mediaAttachment ]; + + // everything is ok + useAlternateText = NO; + } + } + } + } + + // if any problems creating the attachment, use the alternate text if provided + if ((useAlternateText == YES) && (mediaAltText != nil)) { + weakSelf.modifiedNotificationContent.body = mediaAltText; + } + + // tell the OS we are done and here is the new content + weakSelf.contentHandler(weakSelf.modifiedNotificationContent); + }] resume]; + } else { + // see if the media URL is for a local file (i.e., file://movie.mp4) + BOOL useAlternateText = YES; + if (mediaUrlString != nil) { + // attempt to create a URL to a file in local storage + NSURL *localMediaUrl = + [NSURL fileURLWithPath:[[NSBundle mainBundle] + pathForResource:mediaUrlString.lastPathComponent + .stringByDeletingLastPathComponent + ofType:mediaUrlString.pathExtension]]; + + // is the URL a local file URL? + if (localMediaUrl != nil && localMediaUrl.isFileURL == YES) { + // create an attachment with the local media + UNNotificationAttachment *mediaAttachment = + [self createMediaAttachment:localMediaUrl]; + + // if no problems creating the attachment, we can use it + if (mediaAttachment != nil) { + // set the media to display in the notification + self.modifiedNotificationContent.attachments = @[ mediaAttachment ]; + + // everything is ok + useAlternateText = NO; + } + } + } + + // if any problems creating the attachment, use the alternate text if provided + if ((useAlternateText == YES) && (mediaAltText != nil)) { + self.modifiedNotificationContent.body = mediaAltText; + } + + // tell the OS we are done and here is the new content + contentHandler(self.modifiedNotificationContent); + } + } + + - (void)serviceExtensionTimeWillExpire { + // Called just before the extension will be terminated by the system. + // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the + // original push payload will be used. + + // we took too long to download the media URL, use the alternate text if provided + NSString *mediaAltText = self.modifiedNotificationContent.userInfo[@"_mediaAlt"]; + if (mediaAltText != nil) { + self.modifiedNotificationContent.body = mediaAltText; + } + + // tell the OS we are done and here is the new content + self.contentHandler(self.modifiedNotificationContent); + } + + @end + ``` \ No newline at end of file diff --git a/jsdoc2md/TEMPLATE.md b/jsdoc2md/TEMPLATE.md index 1ddd231..e236277 100644 --- a/jsdoc2md/TEMPLATE.md +++ b/jsdoc2md/TEMPLATE.md @@ -1,6 +1,6 @@ # Salesforce Marketing Cloud Cordova Plugin -Use this plugin to implement the Marketing Cloud MobilePush SDK for your [iOS](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/) and [Android](http://salesforce-marketingcloud.github.io/JB4A-SDK-Android/) applications. +Use this plugin to implement the Marketing Cloud MobilePush SDK for your [iOS](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/) and [Android](http://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/) applications. ## Release Notes @@ -53,6 +53,10 @@ To enable push support for the Android platform you will need to include the goo ``` +#### 4. Enable iOS Push + +Follow [these instructions](./ios_push.md) to enable push for iOS. + ## API Reference {{#orphans~}} diff --git a/package.json b/package.json index 790056b..7e1d7ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-marketingcloudsdk", - "version": "6.3.0", + "version": "6.3.1", "description": "A Cordova Plugin to access the native Salesforce Marketing Cloud MobilePush SDKs", "author": "Salesforce Marketing Cloud", "license": "BSD-3-Clause", diff --git a/plugin.xml b/plugin.xml index f89fbc9..d0d61d1 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,5 +1,5 @@ - diff --git a/src/android/MCCordovaPlugin.java b/src/android/MCCordovaPlugin.java index e1f4126..cf9a2c7 100644 --- a/src/android/MCCordovaPlugin.java +++ b/src/android/MCCordovaPlugin.java @@ -30,13 +30,14 @@ import android.content.Intent; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.util.Log; + import com.salesforce.marketingcloud.MCLogListener; import com.salesforce.marketingcloud.MarketingCloudSdk; import com.salesforce.marketingcloud.UrlHandler; import com.salesforce.marketingcloud.notifications.NotificationManager; import com.salesforce.marketingcloud.notifications.NotificationMessage; -import java.util.Collection; -import java.util.Map; + import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaInterface; import org.apache.cordova.CordovaPlugin; @@ -46,6 +47,9 @@ import org.json.JSONException; import org.json.JSONObject; +import java.util.Collection; +import java.util.Map; + public class MCCordovaPlugin extends CordovaPlugin implements UrlHandler { static final String TAG = "~!MCCordova"; @@ -261,6 +265,8 @@ private ActionHandler getActionHandler(String action) { return setContactKey(); case "getContactKey": return getContactKey(); + case "logSdkState": + return logSdkState(); default: return null; } @@ -405,7 +411,26 @@ public void execute( }; } + private ActionHandler logSdkState() { + return new ActionHandler() { + @Override + public void execute( + MarketingCloudSdk sdk, JSONArray args, CallbackContext callbackContext) { + log("MCSDK STATE", sdk.getSdkState().toString()); + callbackContext.success(); + } + }; + } + interface ActionHandler { void execute(MarketingCloudSdk sdk, JSONArray args, CallbackContext callbackContext); } + + private static int MAX_LOG_LENGTH = 4000; + + private static void log(String tag, String msg) { + for (int i = 0, length = msg.length(); i < length; i += MAX_LOG_LENGTH) { + Log.println(Log.DEBUG, tag, msg.substring(i, Math.min(length, i + MAX_LOG_LENGTH))); + } + } } diff --git a/src/android/build/marketingcloudsdk.gradle b/src/android/build/marketingcloudsdk.gradle index 555dc82..f6f4b0f 100644 --- a/src/android/build/marketingcloudsdk.gradle +++ b/src/android/build/marketingcloudsdk.gradle @@ -13,7 +13,7 @@ buildscript { repositories { maven { url "https://maven.google.com" } - maven { url "http://salesforce-marketingcloud.github.io/JB4A-SDK-Android/repository" } + maven { url "http://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" } } dependencies { diff --git a/src/ios/MCCordovaPlugin.h b/src/ios/MCCordovaPlugin.h index 63666c5..e1e1fdd 100644 --- a/src/ios/MCCordovaPlugin.h +++ b/src/ios/MCCordovaPlugin.h @@ -34,6 +34,7 @@ - (void)enableVerboseLogging:(CDVInvokedUrlCommand *)command; - (void)disableVerboseLogging:(CDVInvokedUrlCommand *)command; +- (void)logSdkState:(CDVInvokedUrlCommand *)command; - (void)getSystemToken:(CDVInvokedUrlCommand *)command; - (void)isPushEnabled:(CDVInvokedUrlCommand *)command; @@ -57,5 +58,6 @@ @property(nonatomic, copy) NSString *eventsCallbackId; @property(nonatomic, assign) BOOL notificationOpenedSubscribed; @property(nonatomic, strong) NSDictionary *cachedNotification; +@property(nonatomic, strong) os_log_t logger; @end diff --git a/src/ios/MCCordovaPlugin.m b/src/ios/MCCordovaPlugin.m index d868cea..36763f0 100644 --- a/src/ios/MCCordovaPlugin.m +++ b/src/ios/MCCordovaPlugin.m @@ -29,6 +29,8 @@ @implementation MCCordovaPlugin +const int LOG_LENGTH = 800; + @synthesize eventsCallbackId; @synthesize notificationOpenedSubscribed; @synthesize cachedNotification; @@ -86,6 +88,26 @@ + (NSMutableDictionary *_Nullable)dataForNotificationReceived:(NSNotification *) return notificationData; } +- (void)log:(NSString *)msg { + if (@available(iOS 10, *)) { + if (self.logger == nil) { + self.logger = + os_log_create("com.salesforce.marketingcloud.marketingcloudsdk", "Cordova"); + } + os_log_info(self.logger, "%@", msg); + } else { + NSLog(@"%@", msg); + } +} + +- (void)splitLog:(NSString *)msg { + NSInteger length = msg.length; + for (int i = 0; i < length; i += LOG_LENGTH) { + NSInteger rangeLength = MIN(length - i, LOG_LENGTH); + [self log:[msg substringWithRange:NSMakeRange((NSUInteger)i, (NSUInteger)rangeLength)]]; + } +} + - (void)sfmc_handleURL:(NSURL *)url type:(NSString *)type { if ([type isEqualToString:@"action"] && self.eventsCallbackId != nil) { CDVPluginResult *result = [CDVPluginResult @@ -243,6 +265,12 @@ - (void)disableVerboseLogging:(CDVInvokedUrlCommand *)command { callbackId:command.callbackId]; } +- (void)logSdkState:(CDVInvokedUrlCommand *)command { + [self splitLog:[[MarketingCloudSDK sharedInstance] sfmc_getSDKState]]; + [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] + callbackId:command.callbackId]; +} + - (void)getSystemToken:(CDVInvokedUrlCommand *)command { NSString *systemToken = [[MarketingCloudSDK sharedInstance] sfmc_deviceToken]; diff --git a/tests/android/app/src/test/java/com/salesforce/marketingcloud/cordova/MCCordovaPluginTest.kt b/tests/android/app/src/test/java/com/salesforce/marketingcloud/cordova/MCCordovaPluginTest.kt index ebac57b..ff657c9 100644 --- a/tests/android/app/src/test/java/com/salesforce/marketingcloud/cordova/MCCordovaPluginTest.kt +++ b/tests/android/app/src/test/java/com/salesforce/marketingcloud/cordova/MCCordovaPluginTest.kt @@ -49,6 +49,7 @@ import org.junit.runner.RunWith import org.mockito.Mockito import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config +import org.robolectric.shadows.ShadowLog import java.util.concurrent.ExecutorService @RunWith(RobolectricTestRunner::class) @@ -482,6 +483,22 @@ class MCCordovaPluginTest { } } + @Test + fun logSdkState_printsStateToLog() { + // GIVEN + ShadowMarketingCloudSdk.isReady(true) + val testState = JSONObject().apply { put("state", "a".repeat(4000)) } + given(sdk.sdkState).willReturn(testState) + + // WHEN + val callSuccess = plugin.execute("logSdkState", JSONArray(), callbackContext) + + assertThat(callSuccess).isTrue() + val stateLogs = ShadowLog.getLogsForTag("MCSDK STATE") + assertThat(stateLogs).hasSize(2) // Should have split log into two calls given size of sdk state + verify(callbackContext).success() + } + private fun intentWithMessage(messageId: String = "mId", alert: String = "Alert text", openDirectUrl: String? = null, cloudPageUrl: String? = null): Intent { return Intent().apply { diff --git a/tests/ios/.gitignore b/tests/ios/.gitignore index 4daadba..09f4b82 100644 --- a/tests/ios/.gitignore +++ b/tests/ios/.gitignore @@ -18,4 +18,7 @@ DerivedData xcuserdata/* package-lock.json -node_modules \ No newline at end of file +node_modules + +Pods/ +Podfile.lock \ No newline at end of file diff --git a/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/project.pbxproj b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/project.pbxproj index 30bb991..2f5a046 100644 --- a/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/project.pbxproj +++ b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/project.pbxproj @@ -7,48 +7,26 @@ objects = { /* Begin PBXBuildFile section */ - 3A1BC6692140533E007122F6 /* MCCordovaPluginLibTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A1BC6682140533E007122F6 /* MCCordovaPluginLibTests.m */; }; - 3A1BC66B2140533E007122F6 /* libMCCordovaPluginLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A1BC6562140532B007122F6 /* libMCCordovaPluginLib.a */; }; - 3A1BC67721405425007122F6 /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A1BC67621405425007122F6 /* libOCMock.a */; }; - 3A1BC67A214054B4007122F6 /* MCCordovaPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A1BC679214054B3007122F6 /* MCCordovaPlugin.m */; }; - 3A1BC68921405509007122F6 /* libCordova.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A1BC681214054CD007122F6 /* libCordova.a */; }; - 3A1BC68B21405516007122F6 /* MarketingCloudSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A1BC68A21405516007122F6 /* MarketingCloudSDK.framework */; }; - 3A1BC68D214055A6007122F6 /* MarketingCloudSDK.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 3A1BC68C214055A6007122F6 /* MarketingCloudSDK.bundle */; }; + 3A515F7F228F359E00036F6B /* libCordova.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A515F7E228F359E00036F6B /* libCordova.a */; }; + 3ACBFBA2228F2BC300899187 /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3ACBFBA1228F2BC300899187 /* Tests.m */; }; + 3ACBFBA4228F2BC300899187 /* libMCCordovaPluginLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3ACBFB8F228F2B9D00899187 /* libMCCordovaPluginLib.a */; }; + 3ACBFBAC228F2E7600899187 /* MCCordovaPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 3ACBFBAA228F2E7600899187 /* MCCordovaPlugin.m */; }; + 61B0D6D103B2450154680DFC /* libPods-MCCordovaPluginLib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 96DC5A63310C83190D5A0E4D /* libPods-MCCordovaPluginLib.a */; }; + D252608757EF7590A5370DF4 /* libPods-Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4CA1A461D053DCF774C41814 /* libPods-Tests.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 3A1BC66C2140533E007122F6 /* PBXContainerItemProxy */ = { + 3ACBFBA5228F2BC300899187 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; - containerPortal = 3A1BC64E2140532B007122F6 /* Project object */; + containerPortal = 3ACBFB87228F2B9D00899187 /* Project object */; proxyType = 1; - remoteGlobalIDString = 3A1BC6552140532B007122F6; + remoteGlobalIDString = 3ACBFB8E228F2B9D00899187; remoteInfo = MCCordovaPluginLib; }; - 3A1BC680214054CD007122F6 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 3A1BC67B214054CC007122F6 /* CordovaLib.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 68A32D7114102E1C006B237C; - remoteInfo = CordovaLib; - }; - 3A1BC682214054CD007122F6 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 3A1BC67B214054CC007122F6 /* CordovaLib.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = C0C01EB21E3911D50056E6CB; - remoteInfo = Cordova; - }; - 3A1BC686214054E6007122F6 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 3A1BC67B214054CC007122F6 /* CordovaLib.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = D2AAC07D0554694100DB518D; - remoteInfo = CordovaLib; - }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ - 3A1BC6542140532B007122F6 /* CopyFiles */ = { + 3ACBFB8D228F2B9D00899187 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = "include/$(PRODUCT_NAME)"; @@ -60,263 +38,264 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 3A1BC6562140532B007122F6 /* libMCCordovaPluginLib.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMCCordovaPluginLib.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 3A1BC6662140533E007122F6 /* MCCordovaPluginLibTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MCCordovaPluginLibTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 3A1BC6682140533E007122F6 /* MCCordovaPluginLibTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MCCordovaPluginLibTests.m; sourceTree = ""; usesTabs = 0; }; - 3A1BC66A2140533E007122F6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 3A1BC67621405425007122F6 /* libOCMock.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libOCMock.a; path = usr/lib/libOCMock.a; sourceTree = ""; }; - 3A1BC678214054B3007122F6 /* MCCordovaPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MCCordovaPlugin.h; path = ../../../../src/ios/MCCordovaPlugin.h; sourceTree = ""; }; - 3A1BC679214054B3007122F6 /* MCCordovaPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MCCordovaPlugin.m; path = ../../../../src/ios/MCCordovaPlugin.m; sourceTree = ""; }; - 3A1BC67B214054CC007122F6 /* CordovaLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CordovaLib.xcodeproj; path = "../node_modules/cordova-ios/CordovaLib/CordovaLib.xcodeproj"; sourceTree = ""; }; - 3A1BC68A21405516007122F6 /* MarketingCloudSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MarketingCloudSDK.framework; path = ../../../src/ios/MarketingCloudSDK/MarketingCloudSDK.framework; sourceTree = ""; }; - 3A1BC68C214055A6007122F6 /* MarketingCloudSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = MarketingCloudSDK.bundle; path = ../../../src/ios/MarketingCloudSDK/MarketingCloudSDK.bundle; sourceTree = ""; }; + 3A515F7E228F359E00036F6B /* libCordova.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libCordova.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 3A7E2C39228F317B00168F10 /* libCordova.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libCordova.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 3ACBFB8F228F2B9D00899187 /* libMCCordovaPluginLib.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMCCordovaPluginLib.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 3ACBFB9F228F2BC300899187 /* Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3ACBFBA1228F2BC300899187 /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = ""; }; + 3ACBFBA3228F2BC300899187 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3ACBFBAA228F2E7600899187 /* MCCordovaPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MCCordovaPlugin.m; path = ../../../../src/ios/MCCordovaPlugin.m; sourceTree = ""; }; + 3ACBFBAB228F2E7600899187 /* MCCordovaPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MCCordovaPlugin.h; path = ../../../../src/ios/MCCordovaPlugin.h; sourceTree = ""; }; + 4CA1A461D053DCF774C41814 /* libPods-Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 90D45726C2590366B6A9B0CC /* Pods-MCCordovaPluginLib.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MCCordovaPluginLib.debug.xcconfig"; path = "Target Support Files/Pods-MCCordovaPluginLib/Pods-MCCordovaPluginLib.debug.xcconfig"; sourceTree = ""; }; + 96DC5A63310C83190D5A0E4D /* libPods-MCCordovaPluginLib.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-MCCordovaPluginLib.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + B315E285464CAEAC040D414C /* Pods-Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.release.xcconfig"; path = "Target Support Files/Pods-Tests/Pods-Tests.release.xcconfig"; sourceTree = ""; }; + B8286676AB8BAD6395703CF9 /* Pods-MCCordovaPluginLib.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MCCordovaPluginLib.release.xcconfig"; path = "Target Support Files/Pods-MCCordovaPluginLib/Pods-MCCordovaPluginLib.release.xcconfig"; sourceTree = ""; }; + EB4189AD7C1D1AD692CA1625 /* Pods-Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Tests.debug.xcconfig"; path = "Target Support Files/Pods-Tests/Pods-Tests.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 3A1BC6532140532B007122F6 /* Frameworks */ = { + 3ACBFB8C228F2B9D00899187 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 3A1BC68B21405516007122F6 /* MarketingCloudSDK.framework in Frameworks */, - 3A1BC68921405509007122F6 /* libCordova.a in Frameworks */, + 3A515F7F228F359E00036F6B /* libCordova.a in Frameworks */, + 61B0D6D103B2450154680DFC /* libPods-MCCordovaPluginLib.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; - 3A1BC6632140533E007122F6 /* Frameworks */ = { + 3ACBFB9C228F2BC300899187 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 3A1BC67721405425007122F6 /* libOCMock.a in Frameworks */, - 3A1BC66B2140533E007122F6 /* libMCCordovaPluginLib.a in Frameworks */, + 3ACBFBA4228F2BC300899187 /* libMCCordovaPluginLib.a in Frameworks */, + D252608757EF7590A5370DF4 /* libPods-Tests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 3A1BC64D2140532B007122F6 = { - isa = PBXGroup; - children = ( - 3A1BC68C214055A6007122F6 /* MarketingCloudSDK.bundle */, - 3A1BC67B214054CC007122F6 /* CordovaLib.xcodeproj */, - 3A1BC6722140536D007122F6 /* usr */, - 3A1BC6582140532B007122F6 /* MCCordovaPluginLib */, - 3A1BC6672140533E007122F6 /* MCCordovaPluginLibTests */, - 3A1BC6572140532B007122F6 /* Products */, - 3A1BC67521405425007122F6 /* Frameworks */, - ); - sourceTree = ""; - }; - 3A1BC6572140532B007122F6 /* Products */ = { - isa = PBXGroup; - children = ( - 3A1BC6562140532B007122F6 /* libMCCordovaPluginLib.a */, - 3A1BC6662140533E007122F6 /* MCCordovaPluginLibTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - 3A1BC6582140532B007122F6 /* MCCordovaPluginLib */ = { + 11E39A16D2930658CE322A40 /* Pods */ = { isa = PBXGroup; children = ( - 3A1BC678214054B3007122F6 /* MCCordovaPlugin.h */, - 3A1BC679214054B3007122F6 /* MCCordovaPlugin.m */, + 90D45726C2590366B6A9B0CC /* Pods-MCCordovaPluginLib.debug.xcconfig */, + B8286676AB8BAD6395703CF9 /* Pods-MCCordovaPluginLib.release.xcconfig */, + EB4189AD7C1D1AD692CA1625 /* Pods-Tests.debug.xcconfig */, + B315E285464CAEAC040D414C /* Pods-Tests.release.xcconfig */, ); - path = MCCordovaPluginLib; + path = Pods; sourceTree = ""; }; - 3A1BC6672140533E007122F6 /* MCCordovaPluginLibTests */ = { + 3ACBFB86228F2B9D00899187 = { isa = PBXGroup; children = ( - 3A1BC6682140533E007122F6 /* MCCordovaPluginLibTests.m */, - 3A1BC66A2140533E007122F6 /* Info.plist */, + 3ACBFB91228F2B9D00899187 /* MCCordovaPluginLib */, + 3ACBFBA0228F2BC300899187 /* Tests */, + 3ACBFB90228F2B9D00899187 /* Products */, + 11E39A16D2930658CE322A40 /* Pods */, + BBE93FF81042BCEF58449B6A /* Frameworks */, ); - path = MCCordovaPluginLibTests; sourceTree = ""; }; - 3A1BC6722140536D007122F6 /* usr */ = { + 3ACBFB90228F2B9D00899187 /* Products */ = { isa = PBXGroup; children = ( - 3A1BC67421405399007122F6 /* lib */, - 3A1BC6732140537B007122F6 /* include */, + 3ACBFB8F228F2B9D00899187 /* libMCCordovaPluginLib.a */, + 3ACBFB9F228F2BC300899187 /* Tests.xctest */, ); - path = usr; + name = Products; sourceTree = ""; }; - 3A1BC6732140537B007122F6 /* include */ = { + 3ACBFB91228F2B9D00899187 /* MCCordovaPluginLib */ = { isa = PBXGroup; children = ( + 3ACBFBAB228F2E7600899187 /* MCCordovaPlugin.h */, + 3ACBFBAA228F2E7600899187 /* MCCordovaPlugin.m */, ); - path = include; + path = MCCordovaPluginLib; sourceTree = ""; }; - 3A1BC67421405399007122F6 /* lib */ = { + 3ACBFBA0228F2BC300899187 /* Tests */ = { isa = PBXGroup; children = ( + 3ACBFBA1228F2BC300899187 /* Tests.m */, + 3ACBFBA3228F2BC300899187 /* Info.plist */, ); - path = lib; + path = Tests; sourceTree = ""; }; - 3A1BC67521405425007122F6 /* Frameworks */ = { + BBE93FF81042BCEF58449B6A /* Frameworks */ = { isa = PBXGroup; children = ( - 3A1BC68A21405516007122F6 /* MarketingCloudSDK.framework */, - 3A1BC67621405425007122F6 /* libOCMock.a */, + 3A515F7E228F359E00036F6B /* libCordova.a */, + 3A7E2C39228F317B00168F10 /* libCordova.a */, + 96DC5A63310C83190D5A0E4D /* libPods-MCCordovaPluginLib.a */, + 4CA1A461D053DCF774C41814 /* libPods-Tests.a */, ); name = Frameworks; sourceTree = ""; }; - 3A1BC67C214054CC007122F6 /* Products */ = { - isa = PBXGroup; - children = ( - 3A1BC681214054CD007122F6 /* libCordova.a */, - 3A1BC683214054CD007122F6 /* Cordova.framework */, - ); - name = Products; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 3A1BC6552140532B007122F6 /* MCCordovaPluginLib */ = { + 3ACBFB8E228F2B9D00899187 /* MCCordovaPluginLib */ = { isa = PBXNativeTarget; - buildConfigurationList = 3A1BC65F2140532B007122F6 /* Build configuration list for PBXNativeTarget "MCCordovaPluginLib" */; + buildConfigurationList = 3ACBFB98228F2B9D00899187 /* Build configuration list for PBXNativeTarget "MCCordovaPluginLib" */; buildPhases = ( - 3A1BC6522140532B007122F6 /* Sources */, - 3A1BC6532140532B007122F6 /* Frameworks */, - 3A1BC6542140532B007122F6 /* CopyFiles */, + B9BD4B71FCBD19B39208F6A5 /* [CP] Check Pods Manifest.lock */, + 3ACBFB8B228F2B9D00899187 /* Sources */, + 3ACBFB8C228F2B9D00899187 /* Frameworks */, + 3ACBFB8D228F2B9D00899187 /* CopyFiles */, ); buildRules = ( ); dependencies = ( - 3A1BC687214054E6007122F6 /* PBXTargetDependency */, ); name = MCCordovaPluginLib; productName = MCCordovaPluginLib; - productReference = 3A1BC6562140532B007122F6 /* libMCCordovaPluginLib.a */; + productReference = 3ACBFB8F228F2B9D00899187 /* libMCCordovaPluginLib.a */; productType = "com.apple.product-type.library.static"; }; - 3A1BC6652140533E007122F6 /* MCCordovaPluginLibTests */ = { + 3ACBFB9E228F2BC300899187 /* Tests */ = { isa = PBXNativeTarget; - buildConfigurationList = 3A1BC66E2140533E007122F6 /* Build configuration list for PBXNativeTarget "MCCordovaPluginLibTests" */; + buildConfigurationList = 3ACBFBA7228F2BC300899187 /* Build configuration list for PBXNativeTarget "Tests" */; buildPhases = ( - 3A1BC6622140533E007122F6 /* Sources */, - 3A1BC6632140533E007122F6 /* Frameworks */, - 3A1BC6642140533E007122F6 /* Resources */, + C805576112F1136A5EDF639B /* [CP] Check Pods Manifest.lock */, + 3ACBFB9B228F2BC300899187 /* Sources */, + 3ACBFB9C228F2BC300899187 /* Frameworks */, + 3ACBFB9D228F2BC300899187 /* Resources */, ); buildRules = ( ); dependencies = ( - 3A1BC66D2140533E007122F6 /* PBXTargetDependency */, + 3ACBFBA6228F2BC300899187 /* PBXTargetDependency */, ); - name = MCCordovaPluginLibTests; - productName = MCCordovaPluginLibTests; - productReference = 3A1BC6662140533E007122F6 /* MCCordovaPluginLibTests.xctest */; + name = Tests; + productName = Tests; + productReference = 3ACBFB9F228F2BC300899187 /* Tests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ - 3A1BC64E2140532B007122F6 /* Project object */ = { + 3ACBFB87228F2B9D00899187 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0940; - ORGANIZATIONNAME = "Seth Clark"; + LastUpgradeCheck = 1020; TargetAttributes = { - 3A1BC6552140532B007122F6 = { - CreatedOnToolsVersion = 9.4.1; + 3ACBFB8E228F2B9D00899187 = { + CreatedOnToolsVersion = 10.2.1; }; - 3A1BC6652140533E007122F6 = { - CreatedOnToolsVersion = 9.4.1; + 3ACBFB9E228F2BC300899187 = { + CreatedOnToolsVersion = 10.2.1; }; }; }; - buildConfigurationList = 3A1BC6512140532B007122F6 /* Build configuration list for PBXProject "MCCordovaPluginLib" */; + buildConfigurationList = 3ACBFB8A228F2B9D00899187 /* Build configuration list for PBXProject "MCCordovaPluginLib" */; compatibilityVersion = "Xcode 9.3"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, ); - mainGroup = 3A1BC64D2140532B007122F6; - productRefGroup = 3A1BC6572140532B007122F6 /* Products */; + mainGroup = 3ACBFB86228F2B9D00899187; + productRefGroup = 3ACBFB90228F2B9D00899187 /* Products */; projectDirPath = ""; - projectReferences = ( - { - ProductGroup = 3A1BC67C214054CC007122F6 /* Products */; - ProjectRef = 3A1BC67B214054CC007122F6 /* CordovaLib.xcodeproj */; - }, - ); projectRoot = ""; targets = ( - 3A1BC6552140532B007122F6 /* MCCordovaPluginLib */, - 3A1BC6652140533E007122F6 /* MCCordovaPluginLibTests */, + 3ACBFB8E228F2B9D00899187 /* MCCordovaPluginLib */, + 3ACBFB9E228F2BC300899187 /* Tests */, ); }; /* End PBXProject section */ -/* Begin PBXReferenceProxy section */ - 3A1BC681214054CD007122F6 /* libCordova.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libCordova.a; - remoteRef = 3A1BC680214054CD007122F6 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 3A1BC683214054CD007122F6 /* Cordova.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = Cordova.framework; - remoteRef = 3A1BC682214054CD007122F6 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - /* Begin PBXResourcesBuildPhase section */ - 3A1BC6642140533E007122F6 /* Resources */ = { + 3ACBFB9D228F2BC300899187 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3A1BC68D214055A6007122F6 /* MarketingCloudSDK.bundle in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + B9BD4B71FCBD19B39208F6A5 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-MCCordovaPluginLib-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + C805576112F1136A5EDF639B /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Tests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ - 3A1BC6522140532B007122F6 /* Sources */ = { + 3ACBFB8B228F2B9D00899187 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3A1BC67A214054B4007122F6 /* MCCordovaPlugin.m in Sources */, + 3ACBFBAC228F2E7600899187 /* MCCordovaPlugin.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; - 3A1BC6622140533E007122F6 /* Sources */ = { + 3ACBFB9B228F2BC300899187 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3A1BC6692140533E007122F6 /* MCCordovaPluginLibTests.m in Sources */, + 3ACBFBA2228F2BC300899187 /* Tests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 3A1BC66D2140533E007122F6 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 3A1BC6552140532B007122F6 /* MCCordovaPluginLib */; - targetProxy = 3A1BC66C2140533E007122F6 /* PBXContainerItemProxy */; - }; - 3A1BC687214054E6007122F6 /* PBXTargetDependency */ = { + 3ACBFBA6228F2BC300899187 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - name = CordovaLib; - targetProxy = 3A1BC686214054E6007122F6 /* PBXContainerItemProxy */; + target = 3ACBFB8E228F2B9D00899187 /* MCCordovaPluginLib */; + targetProxy = 3ACBFBA5228F2BC300899187 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ - 3A1BC65D2140532B007122F6 /* Debug */ = { + 3ACBFB96228F2B9D00899187 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -367,14 +346,15 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.4; - MTL_ENABLE_DEBUG_INFO = YES; + IPHONEOS_DEPLOYMENT_TARGET = 12.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; name = Debug; }; - 3A1BC65E2140532B007122F6 /* Release */ = { + 3ACBFB97228F2B9D00899187 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; @@ -419,74 +399,65 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.4; + IPHONEOS_DEPLOYMENT_TARGET = 12.2; MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; name = Release; }; - 3A1BC6602140532B007122F6 /* Debug */ = { + 3ACBFB99228F2B9D00899187 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 90D45726C2590366B6A9B0CC /* Pods-MCCordovaPluginLib.debug.xcconfig */; buildSettings = { CODE_SIGN_STYLE = Automatic; - FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../../../src/ios/MarketingCloudSDK\""; - HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../node_modules/cordova-ios/CordovaLib\"/**"; - OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; - 3A1BC6612140532B007122F6 /* Release */ = { + 3ACBFB9A228F2B9D00899187 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = B8286676AB8BAD6395703CF9 /* Pods-MCCordovaPluginLib.release.xcconfig */; buildSettings = { CODE_SIGN_STYLE = Automatic; - FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../../../src/ios/MarketingCloudSDK\""; - HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../node_modules/cordova-ios/CordovaLib\"/**"; - OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; - 3A1BC66F2140533E007122F6 /* Debug */ = { + 3ACBFBA8228F2BC300899187 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = EB4189AD7C1D1AD692CA1625 /* Pods-Tests.debug.xcconfig */; buildSettings = { CODE_SIGN_STYLE = Automatic; - FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../../../src/ios/MarketingCloudSDK\""; - HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/usr/include"; - INFOPLIST_FILE = MCCordovaPluginLibTests/Info.plist; + INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/usr/lib"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_BUNDLE_IDENTIFIER = com.salesforce.marketingcloud.cordova.MCCordovaPluginLibTests; + PRODUCT_BUNDLE_IDENTIFIER = com.salesforce.marketingcloud.Tests; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; - 3A1BC6702140533E007122F6 /* Release */ = { + 3ACBFBA9228F2BC300899187 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = B315E285464CAEAC040D414C /* Pods-Tests.release.xcconfig */; buildSettings = { CODE_SIGN_STYLE = Automatic; - FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/../../../src/ios/MarketingCloudSDK\""; - HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/usr/include"; - INFOPLIST_FILE = MCCordovaPluginLibTests/Info.plist; + INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", "@loader_path/Frameworks", ); - LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/usr/lib"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_BUNDLE_IDENTIFIER = com.salesforce.marketingcloud.cordova.MCCordovaPluginLibTests; + PRODUCT_BUNDLE_IDENTIFIER = com.salesforce.marketingcloud.Tests; PRODUCT_NAME = "$(TARGET_NAME)"; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -495,34 +466,34 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 3A1BC6512140532B007122F6 /* Build configuration list for PBXProject "MCCordovaPluginLib" */ = { + 3ACBFB8A228F2B9D00899187 /* Build configuration list for PBXProject "MCCordovaPluginLib" */ = { isa = XCConfigurationList; buildConfigurations = ( - 3A1BC65D2140532B007122F6 /* Debug */, - 3A1BC65E2140532B007122F6 /* Release */, + 3ACBFB96228F2B9D00899187 /* Debug */, + 3ACBFB97228F2B9D00899187 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 3A1BC65F2140532B007122F6 /* Build configuration list for PBXNativeTarget "MCCordovaPluginLib" */ = { + 3ACBFB98228F2B9D00899187 /* Build configuration list for PBXNativeTarget "MCCordovaPluginLib" */ = { isa = XCConfigurationList; buildConfigurations = ( - 3A1BC6602140532B007122F6 /* Debug */, - 3A1BC6612140532B007122F6 /* Release */, + 3ACBFB99228F2B9D00899187 /* Debug */, + 3ACBFB9A228F2B9D00899187 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 3A1BC66E2140533E007122F6 /* Build configuration list for PBXNativeTarget "MCCordovaPluginLibTests" */ = { + 3ACBFBA7228F2BC300899187 /* Build configuration list for PBXNativeTarget "Tests" */ = { isa = XCConfigurationList; buildConfigurations = ( - 3A1BC66F2140533E007122F6 /* Debug */, - 3A1BC6702140533E007122F6 /* Release */, + 3ACBFBA8228F2BC300899187 /* Debug */, + 3ACBFBA9228F2BC300899187 /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; - rootObject = 3A1BC64E2140532B007122F6 /* Project object */; + rootObject = 3ACBFB87228F2B9D00899187 /* Project object */; } diff --git a/tests/ios/MCCordovaPluginTest.xcworkspace/contents.xcworkspacedata b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 59% rename from tests/ios/MCCordovaPluginTest.xcworkspace/contents.xcworkspacedata rename to tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 3d72499..9badb17 100644 --- a/tests/ios/MCCordovaPluginTest.xcworkspace/contents.xcworkspacedata +++ b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:MCCordovaPluginLib.xcodeproj"> diff --git a/tests/ios/MCCordovaPluginTest.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from tests/ios/MCCordovaPluginTest.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/xcshareddata/xcschemes/MCCordovaPluginLib.xcscheme b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/xcshareddata/xcschemes/MCCordovaPluginLib.xcscheme index 51c01c8..4548cd7 100644 --- a/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/xcshareddata/xcschemes/MCCordovaPluginLib.xcscheme +++ b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/xcshareddata/xcschemes/MCCordovaPluginLib.xcscheme @@ -1,6 +1,6 @@ @@ -32,9 +32,9 @@ skipped = "NO"> @@ -42,7 +42,7 @@ @@ -64,7 +64,7 @@ @@ -82,7 +82,7 @@ diff --git a/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme new file mode 100644 index 0000000..c76cefd --- /dev/null +++ b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcworkspace/contents.xcworkspacedata b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..c3e3fe9 --- /dev/null +++ b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/tests/ios/MCCordovaPluginLib/MCCordovaPluginLib.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/tests/ios/MCCordovaPluginLib/Podfile b/tests/ios/MCCordovaPluginLib/Podfile new file mode 100644 index 0000000..2af02de --- /dev/null +++ b/tests/ios/MCCordovaPluginLib/Podfile @@ -0,0 +1,17 @@ +# Uncomment the next line to define a global platform for your project +# platform :ios, '9.0' + +target 'MCCordovaPluginLib' do + # Uncomment the next line if you're using Swift or would like to use dynamic frameworks + # use_frameworks! + pod 'MarketingCloudSDK', '~> 6.2' + pod 'Cordova', '~> 4.5.4' + + # Pods for MCCordovaPluginLib + target 'Tests' do + inherit! :search_paths + pod 'OCMock', '~> 3.4.3' + + end + +end diff --git a/tests/ios/MCCordovaPluginLib/MCCordovaPluginLibTests/Info.plist b/tests/ios/MCCordovaPluginLib/Tests/Info.plist similarity index 100% rename from tests/ios/MCCordovaPluginLib/MCCordovaPluginLibTests/Info.plist rename to tests/ios/MCCordovaPluginLib/Tests/Info.plist diff --git a/tests/ios/MCCordovaPluginLib/MCCordovaPluginLibTests/MCCordovaPluginLibTests.m b/tests/ios/MCCordovaPluginLib/Tests/Tests.m similarity index 61% rename from tests/ios/MCCordovaPluginLib/MCCordovaPluginLibTests/MCCordovaPluginLibTests.m rename to tests/ios/MCCordovaPluginLib/Tests/Tests.m index 651759b..7f2c1f9 100644 --- a/tests/ios/MCCordovaPluginLib/MCCordovaPluginLibTests/MCCordovaPluginLibTests.m +++ b/tests/ios/MCCordovaPluginLib/Tests/Tests.m @@ -1,4 +1,4 @@ -// MCCordovaPluginLibTests.m +// Tests.m // // Copyright (c) 2018 Salesforce, Inc // @@ -30,23 +30,25 @@ #import #import "MCCordovaPlugin.h" -@interface MCCordovaPluginLibTests : XCTestCase +@interface Tests : XCTestCase + @property(strong, nonatomic) id sdk; @property(strong, nonatomic) MCCordovaPlugin *plugin; @property(strong, nonatomic) id commandDelegate; + @end -@implementation MCCordovaPluginLibTests +@implementation Tests - (void)setUp { [super setUp]; - + _sdk = OCMClassMock([MarketingCloudSDK class]); OCMStub(ClassMethod([_sdk sharedInstance])).andReturn(_sdk); - + _plugin = [MCCordovaPlugin alloc]; [_plugin pluginInitialize]; - + _commandDelegate = OCMProtocolMock(@protocol(CDVCommandDelegate)); _plugin.commandDelegate = _commandDelegate; } @@ -63,17 +65,17 @@ - (void)testEnableVerboseLogging { callbackId:@"testCallback" className:@"MCCordovaPlugin" methodName:@"enableVerboseLogging"]; - + // WHEN [_plugin enableVerboseLogging:command]; - + // THEN OCMVerify([_sdk sfmc_setDebugLoggingEnabled:YES]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK; + }] + callbackId:@"testCallback"]); } - (void)testDisableVerboseLogging { @@ -82,19 +84,39 @@ - (void)testDisableVerboseLogging { callbackId:@"testCallback" className:@"MCCordovaPlugin" methodName:@"disableVerboseLogging"]; - + // WHEN [_plugin disableVerboseLogging:command]; - + // THEN OCMVerify([_sdk sfmc_setDebugLoggingEnabled:NO]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK; + }] + callbackId:@"testCallback"]); } +-(void)testLogSdkState { + //GIVEN + id command = [[CDVInvokedUrlCommand alloc] initWithArguments:@[] + callbackId:@"testCallback" + className:@"MCCordovaPlugin" + methodName:@"logSdkState"]; + + // WHEN + [_plugin logSdkState:command]; + + // THEN + OCMVerify([_sdk sfmc_getSDKState]); + OCMVerify([_commandDelegate + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK; + }] + callbackId:@"testCallback"]); +} + + - (void)testGetSystemToken { // GIVEN id command = [[CDVInvokedUrlCommand alloc] initWithArguments:@[] @@ -102,18 +124,18 @@ - (void)testGetSystemToken { className:@"MCCordovaPlugin" methodName:@"getSystemToken"]; OCMStub([_sdk sfmc_deviceToken]).andReturn(@"testSystemToken"); - + // WHEN [_plugin getSystemToken:command]; - + // THEN OCMVerify([_sdk sfmc_deviceToken]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && - [result.message isEqualToString:@"testSystemToken"]; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && + [result.message isEqualToString:@"testSystemToken"]; + }] + callbackId:@"testCallback"]); } - (void)testIsPushEnabled_NO { @@ -123,17 +145,17 @@ - (void)testIsPushEnabled_NO { className:@"MCCordovaPlugin" methodName:@"isPushEnabled"]; OCMStub([_sdk sfmc_pushEnabled]).andReturn(NO); - + // WHEN [_plugin isPushEnabled:command]; - + // THEN OCMVerify([_sdk sfmc_pushEnabled]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 0; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 0; + }] + callbackId:@"testCallback"]); } - (void)testIsPushEnabled_YES { @@ -143,17 +165,17 @@ - (void)testIsPushEnabled_YES { className:@"MCCordovaPlugin" methodName:@"isPushEnabled"]; OCMStub([_sdk sfmc_pushEnabled]).andReturn(YES); - + // WHEN [_plugin isPushEnabled:command]; - + // THEN OCMVerify([_sdk sfmc_pushEnabled]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 1; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 1; + }] + callbackId:@"testCallback"]); } - (void)testEnablePush { @@ -162,17 +184,17 @@ - (void)testEnablePush { callbackId:@"testCallback" className:@"MCCordovaPlugin" methodName:@"enablePush"]; - + // WHEN [_plugin enablePush:command]; - + // THEN OCMVerify([_sdk sfmc_setPushEnabled:YES]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK; + }] + callbackId:@"testCallback"]); } - (void)testDisablePush { @@ -181,17 +203,17 @@ - (void)testDisablePush { callbackId:@"testCallback" className:@"MCCordovaPlugin" methodName:@"disablePush"]; - + // WHEN [_plugin disablePush:command]; - + // THEN OCMVerify([_sdk sfmc_setPushEnabled:NO]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK; + }] + callbackId:@"testCallback"]); } - (void)testSetAttribute_success { @@ -201,17 +223,17 @@ - (void)testSetAttribute_success { className:@"MCCordovaPlugin" methodName:@"setAttribute"]; OCMStub([_sdk sfmc_setAttributeNamed:[OCMArg any] value:[OCMArg any]]).andReturn(YES); - + // WHEN [_plugin setAttribute:command]; - + // THEN OCMVerify([_sdk sfmc_setAttributeNamed:@"TestKey" value:@"TestValue"]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 1; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 1; + }] + callbackId:@"testCallback"]); } - (void)testSetAttribute_failed { @@ -221,17 +243,17 @@ - (void)testSetAttribute_failed { className:@"MCCordovaPlugin" methodName:@"setAttribute"]; OCMStub([_sdk sfmc_setAttributeNamed:[OCMArg any] value:[OCMArg any]]).andReturn(NO); - + // WHEN [_plugin setAttribute:command]; - + // THEN OCMVerify([_sdk sfmc_setAttributeNamed:@"TestKey" value:@"TestValue"]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 0; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 0; + }] + callbackId:@"testCallback"]); } - (void)testClearAttribute_success { @@ -241,17 +263,17 @@ - (void)testClearAttribute_success { className:@"MCCordovaPlugin" methodName:@"clearAttribute"]; OCMStub([_sdk sfmc_clearAttributeNamed:[OCMArg any]]).andReturn(YES); - + // WHEN [_plugin clearAttribute:command]; - + // THEN OCMVerify([_sdk sfmc_clearAttributeNamed:@"TestKey"]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 1; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 1; + }] + callbackId:@"testCallback"]); } - (void)testClearAttribute_failed { @@ -261,17 +283,17 @@ - (void)testClearAttribute_failed { className:@"MCCordovaPlugin" methodName:@"clearAttribute"]; OCMStub([_sdk sfmc_clearAttributeNamed:[OCMArg any]]).andReturn(NO); - + // WHEN [_plugin clearAttribute:command]; - + // THEN OCMVerify([_sdk sfmc_clearAttributeNamed:@"TestKey"]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 0; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 0; + }] + callbackId:@"testCallback"]); } - (void)testGetAttributes { @@ -281,19 +303,19 @@ - (void)testGetAttributes { className:@"MCCordovaPlugin" methodName:@"getAttributes"]; OCMStub([_sdk sfmc_attributes]).andReturn(@{@"TestKey" : @"TestVal"}); - + // WHEN [_plugin getAttributes:command]; - + // THEN OCMVerify([_sdk sfmc_attributes]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return - [result.status intValue] == CDVCommandStatus_OK && - [[(NSDictionary *)result.message valueForKey:@"TestKey"] isEqualToString:@"TestVal"]; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return + [result.status intValue] == CDVCommandStatus_OK && + [[(NSDictionary *)result.message valueForKey:@"TestKey"] isEqualToString:@"TestVal"]; + }] + callbackId:@"testCallback"]); } - (void)testGetAttributes_nil { @@ -303,18 +325,18 @@ - (void)testGetAttributes_nil { className:@"MCCordovaPlugin" methodName:@"getAttributes"]; OCMStub([_sdk sfmc_attributes]).andReturn(nil); - + // WHEN [_plugin getAttributes:command]; - + // THEN OCMVerify([_sdk sfmc_attributes]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && result.message != nil && - [(NSDictionary *)result.message count] == 0; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && result.message != nil && + [(NSDictionary *)result.message count] == 0; + }] + callbackId:@"testCallback"]); } - (void)testGetContactKey { @@ -324,18 +346,18 @@ - (void)testGetContactKey { className:@"MCCordovaPlugin" methodName:@"getContactKey"]; OCMStub([_sdk sfmc_contactKey]).andReturn(@"testContactKey"); - + // WHEN [_plugin getContactKey:command]; - + // THEN OCMVerify([_sdk sfmc_contactKey]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && - [result.message isEqualToString:@"testContactKey"]; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && + [result.message isEqualToString:@"testContactKey"]; + }] + callbackId:@"testCallback"]); } - (void)testSetContactKey_success { @@ -345,17 +367,17 @@ - (void)testSetContactKey_success { className:@"MCCordovaPlugin" methodName:@"setContactKey"]; OCMStub([_sdk sfmc_setContactKey:[OCMArg any]]).andReturn(YES); - + // WHEN [_plugin setContactKey:command]; - + // THEN OCMVerify([_sdk sfmc_setContactKey:@"testContactKey"]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 1; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 1; + }] + callbackId:@"testCallback"]); } - (void)testSetContactKey_failed { @@ -365,17 +387,17 @@ - (void)testSetContactKey_failed { className:@"MCCordovaPlugin" methodName:@"setContactKey"]; OCMStub([_sdk sfmc_setContactKey:[OCMArg any]]).andReturn(NO); - + // WHEN [_plugin setContactKey:command]; - + // THEN OCMVerify([_sdk sfmc_setContactKey:@"testContactKey"]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 0; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 0; + }] + callbackId:@"testCallback"]); } - (void)testAddTag_success { @@ -385,17 +407,17 @@ - (void)testAddTag_success { className:@"MCCordovaPlugin" methodName:@"addTag"]; OCMStub([_sdk sfmc_addTag:[OCMArg any]]).andReturn(YES); - + // WHEN [_plugin addTag:command]; - + // THEN OCMVerify([_sdk sfmc_addTag:@"testTag"]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 1; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 1; + }] + callbackId:@"testCallback"]); } - (void)testAddTag_failed { @@ -405,17 +427,17 @@ - (void)testAddTag_failed { className:@"MCCordovaPlugin" methodName:@"addTag"]; OCMStub([_sdk sfmc_addTag:[OCMArg any]]).andReturn(NO); - + // WHEN [_plugin addTag:command]; - + // THEN OCMVerify([_sdk sfmc_addTag:@"testTag"]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 0; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 0; + }] + callbackId:@"testCallback"]); } - (void)testRemoveTag_success { @@ -425,17 +447,17 @@ - (void)testRemoveTag_success { className:@"MCCordovaPlugin" methodName:@"removeTag"]; OCMStub([_sdk sfmc_removeTag:[OCMArg any]]).andReturn(YES); - + // WHEN [_plugin removeTag:command]; - + // THEN OCMVerify([_sdk sfmc_removeTag:@"testTag"]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 1; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 1; + }] + callbackId:@"testCallback"]); } - (void)testRemoveTag_failed { @@ -445,17 +467,17 @@ - (void)testRemoveTag_failed { className:@"MCCordovaPlugin" methodName:@"removeTag"]; OCMStub([_sdk sfmc_removeTag:[OCMArg any]]).andReturn(NO); - + // WHEN [_plugin removeTag:command]; - + // THEN OCMVerify([_sdk sfmc_removeTag:@"testTag"]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 0; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && [result.message intValue] == 0; + }] + callbackId:@"testCallback"]); } - (void)testGetTags { @@ -466,20 +488,20 @@ - (void)testGetTags { methodName:@"getTags"]; NSArray *tags = @[ @"Tag1", @"Tag2" ]; OCMStub([_sdk sfmc_tags]).andReturn(tags); - + // WHEN [_plugin getTags:command]; - + // THEN OCMVerify([_sdk sfmc_tags]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - NSArray *resultTags = (NSArray *)result.message; - return [result.status intValue] == CDVCommandStatus_OK && resultTags != nil && - [[resultTags objectAtIndex:0] isEqualToString:@"Tag1"] && - [[resultTags objectAtIndex:1] isEqualToString:@"Tag2"]; - }] - callbackId:@"testCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + NSArray *resultTags = (NSArray *)result.message; + return [result.status intValue] == CDVCommandStatus_OK && resultTags != nil && + [[resultTags objectAtIndex:0] isEqualToString:@"Tag1"] && + [[resultTags objectAtIndex:1] isEqualToString:@"Tag2"]; + }] + callbackId:@"testCallback"]); } - (void)testGetTags_nil { @@ -489,171 +511,148 @@ - (void)testGetTags_nil { className:@"MCCordovaPlugin" methodName:@"getTags"]; OCMStub([_sdk sfmc_tags]).andReturn(nil); - + // WHEN [_plugin getTags:command]; - + // THEN OCMVerify([_sdk sfmc_tags]); OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [result.status intValue] == CDVCommandStatus_OK && result.message != nil && - [(NSArray *)result.message count] == 0; - }] - callbackId:@"testCallback"]); -} - -- (void)testUrlHandler_sendsActionUrlAsResult { - // GIVEN - NSString *url = @"https://www.salesforce.com"; - [_plugin registerEventsChannel:[MCCordovaPluginLibTests eventCallbackCommand]]; - - // WHEN - [_plugin sfmc_handleURL:[NSURL URLWithString:url] type:@"action"]; - - // THEN - OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - XCTAssertEqual([result.status intValue], CDVCommandStatus_OK); - XCTAssertTrue([result.message isKindOfClass:[NSDictionary class]]); - XCTAssertTrue(result.keepCallback); - - NSDictionary *message = result.message; - XCTAssertEqualObjects(message[@"type"], @"urlAction"); - XCTAssertEqualObjects(message[@"url"], url); - return YES; - }] - callbackId:@"eventCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [result.status intValue] == CDVCommandStatus_OK && result.message != nil && + [(NSArray *)result.message count] == 0; + }] + callbackId:@"testCallback"]); } - (void) - testNotificationReceived_beforeEventCallbackCalled_beforeSubscribeCalled_shouldBeDeliveredWhenSubscribed { +testNotificationReceived_beforeEventCallbackCalled_beforeSubscribeCalled_shouldBeDeliveredWhenSubscribed { // GIVEN [self sendTestNotification:@{@"aps" : @{}}]; - [_plugin registerEventsChannel:[MCCordovaPluginLibTests eventCallbackCommand]]; - + [_plugin registerEventsChannel:[Tests eventCallbackCommand]]; + // WHEN - [_plugin subscribe:[MCCordovaPluginLibTests notificationOpenedSubscribeCommand]]; - + [_plugin subscribe:[Tests notificationOpenedSubscribeCommand]]; + // THEN OCMVerify([_commandDelegate sendPluginResult:[OCMArg any] callbackId:@"eventCallback"]); } - (void) - testNotificationReceived_afterEventCallbackCalled_beforeSubscribeCalled_shouldBeDeliveredWhenSubscribed { +testNotificationReceived_afterEventCallbackCalled_beforeSubscribeCalled_shouldBeDeliveredWhenSubscribed { // GIVEN - [_plugin registerEventsChannel:[MCCordovaPluginLibTests eventCallbackCommand]]; + [_plugin registerEventsChannel:[Tests eventCallbackCommand]]; [self sendTestNotification:@{@"aps" : @{}}]; - + // WHEN - [_plugin subscribe:[MCCordovaPluginLibTests notificationOpenedSubscribeCommand]]; - + [_plugin subscribe:[Tests notificationOpenedSubscribeCommand]]; + // THEN OCMVerify([_commandDelegate sendPluginResult:[OCMArg any] callbackId:@"eventCallback"]); } - (void) - testNotificationReceived_afterEventCallbackCalled_afterSubscribeCalled_shouldBeDeliveredImmediately { +testNotificationReceived_afterEventCallbackCalled_afterSubscribeCalled_shouldBeDeliveredImmediately { // GIVEN - [_plugin registerEventsChannel:[MCCordovaPluginLibTests eventCallbackCommand]]; - [_plugin subscribe:[MCCordovaPluginLibTests notificationOpenedSubscribeCommand]]; - + [_plugin registerEventsChannel:[Tests eventCallbackCommand]]; + [_plugin subscribe:[Tests notificationOpenedSubscribeCommand]]; + // WHEN [self sendTestNotification:@{@"aps" : @{}}]; - + // THEN OCMVerify([_commandDelegate sendPluginResult:[OCMArg any] callbackId:@"eventCallback"]); } - (void)testNotificationReceived_OD_withAlertTitleSubTitle { // GIVEN - [_plugin registerEventsChannel:[MCCordovaPluginLibTests eventCallbackCommand]]; - [_plugin subscribe:[MCCordovaPluginLibTests notificationOpenedSubscribeCommand]]; - + [_plugin registerEventsChannel:[Tests eventCallbackCommand]]; + [_plugin subscribe:[Tests notificationOpenedSubscribeCommand]]; + NSDictionary *payload = @{ - @"_sid" : @"SFMC", - @"_m" : @"messageId", - @"_od" : @"http://salesforce.com", - @"aps" : @{ - @"alert" : @{ - @"body" : @"Alert Body", - @"title" : @"Alert Title", - @"subtitle" : @"Alert Subtitle" - } - } - }; - + @"_sid" : @"SFMC", + @"_m" : @"messageId", + @"_od" : @"http://salesforce.com", + @"aps" : @{ + @"alert" : @{ + @"body" : @"Alert Body", + @"title" : @"Alert Title", + @"subtitle" : @"Alert Subtitle" + } + } + }; + // WHEN [self sendTestNotification:payload]; - + // THEN OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [self validateResult:result forOpenedNotification:payload]; - }] - callbackId:@"eventCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [self validateResult:result forOpenedNotification:payload]; + }] + callbackId:@"eventCallback"]); } - (void)testNotificationReceived_CP_withAlert_old { // GIVEN - [_plugin registerEventsChannel:[MCCordovaPluginLibTests eventCallbackCommand]]; - [_plugin subscribe:[MCCordovaPluginLibTests notificationOpenedSubscribeCommand]]; - + [_plugin registerEventsChannel:[Tests eventCallbackCommand]]; + [_plugin subscribe:[Tests notificationOpenedSubscribeCommand]]; + NSDictionary *payload = @{ - @"_sid" : @"SFMC", - @"_m" : @"messageId", - @"_x" : @"http://salesforce.com", - @"aps" : @{@"alert" : @"Alert Body"} - }; - + @"_sid" : @"SFMC", + @"_m" : @"messageId", + @"_x" : @"http://salesforce.com", + @"aps" : @{@"alert" : @"Alert Body"} + }; + // WHEN [self sendTestNotification:payload]; - + // THEN OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [self validateResult:result forOpenedNotification:payload]; - }] - callbackId:@"eventCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [self validateResult:result forOpenedNotification:payload]; + }] + callbackId:@"eventCallback"]); } - (void)testNotificationReceived_noUrl_withAlertTitle { // GIVEN - [_plugin registerEventsChannel:[MCCordovaPluginLibTests eventCallbackCommand]]; - [_plugin subscribe:[MCCordovaPluginLibTests notificationOpenedSubscribeCommand]]; - + [_plugin registerEventsChannel:[Tests eventCallbackCommand]]; + [_plugin subscribe:[Tests notificationOpenedSubscribeCommand]]; + NSDictionary *payload = @{ - @"_sid" : @"SFMC", - @"_m" : @"messageId", - @"aps" : @{@"alert" : @{@"body" : @"Alert Body", @"title" : @"Alert Title"}} - }; - + @"_sid" : @"SFMC", + @"_m" : @"messageId", + @"aps" : @{@"alert" : @{@"body" : @"Alert Body", @"title" : @"Alert Title"}} + }; + // WHEN [self sendTestNotification:payload]; - + // THEN OCMVerify([_commandDelegate - sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { - return [self validateResult:result forOpenedNotification:payload]; - }] - callbackId:@"eventCallback"]); + sendPluginResult:[OCMArg checkWithBlock:^BOOL(CDVPluginResult *result) { + return [self validateResult:result forOpenedNotification:payload]; + }] + callbackId:@"eventCallback"]); } - (void)testNotificationReceived_silentPush_notSentToCordova { // GIVEN - [_plugin registerEventsChannel:[MCCordovaPluginLibTests eventCallbackCommand]]; - [_plugin subscribe:[MCCordovaPluginLibTests notificationOpenedSubscribeCommand]]; - + [_plugin registerEventsChannel:[Tests eventCallbackCommand]]; + [_plugin subscribe:[Tests notificationOpenedSubscribeCommand]]; + NSDictionary *payload = - @{@"_sid" : @"SFMC", @"_m" : @"messageId", @"aps" : @{@"content-available" : @1}}; - + @{@"_sid" : @"SFMC", @"_m" : @"messageId", @"aps" : @{@"content-available" : @1}}; + // Hack in failure when sendPluginResult it called. Couldn't seem to get OCMock's `reject` to // work... OCMStub([_commandDelegate sendPluginResult:[OCMArg any] callbackId:[OCMArg any]]) - .andDo(^(NSInvocation *invocation) { - XCTFail("sendPluginResult should not be called"); - }); - + .andDo(^(NSInvocation *invocation) { + XCTFail("sendPluginResult should not be called"); + }); + // WHEN [self sendTestNotification:payload]; } @@ -664,60 +663,61 @@ - (void)sendTestNotification:(NSDictionary *)notification { UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"NDY5NjoxMTQ6MA" content:content trigger:nil]; - + [[NSNotificationCenter defaultCenter] - postNotificationName:SFMCFoundationUNNotificationReceivedNotification - object:self - userInfo:@{ - @"SFMCFoundationUNNotificationReceivedNotificationKeyUNNotificationReques" - @"t" : request - }]; + postNotificationName:SFMCFoundationUNNotificationReceivedNotification + object:self + userInfo:@{ + @"SFMCFoundationUNNotificationReceivedNotificationKeyUNNotificationReques" + @"t" : request + }]; } - (BOOL)validateResult:(CDVPluginResult *)result - forOpenedNotification:(NSDictionary *)notification { + forOpenedNotification:(NSDictionary *)notification { XCTAssertEqual([result.status intValue], CDVCommandStatus_OK); XCTAssertTrue([result.message isKindOfClass:[NSDictionary class]]); XCTAssertTrue(result.keepCallback); - + NSDictionary *message = result.message; - XCTAssertTrue([message[@"timeStamp"] isKindOfClass:[NSNumber class]]); - XCTAssertEqualObjects(message[@"type"], @"notificationOpened"); - XCTAssertTrue([message[@"values"] isKindOfClass:[NSDictionary class]]); - NSDictionary *values = message[@"values"]; - + XCTAssertTrue([[message objectForKey:@"timeStamp"] isKindOfClass:[NSNumber class]]); + XCTAssertEqualObjects([message objectForKey:@"type"], @"notificationOpened"); + XCTAssertTrue([[message objectForKey:@"values"] isKindOfClass:[NSDictionary class]]); + NSDictionary *values = [message objectForKey:@"values"]; + NSSet *notificationKeys = [NSSet setWithArray:notification.allKeys]; Boolean hadUrl = false; for (id key in notificationKeys) { if ([key isEqualToString:@"aps"]) { - NSDictionary *aps = notification[key]; - if ([aps[@"alert"] isKindOfClass:[NSDictionary class]]) { - NSDictionary *alert = aps[@"alert"]; + NSDictionary *aps = [notification objectForKey:key]; + if ([[aps objectForKey:@"alert"] isKindOfClass:[NSDictionary class]]) { + NSDictionary *alert = [aps objectForKey:@"alert"]; NSSet *alertKeys = [NSSet setWithArray:alert.allKeys]; for (id alertKey in alertKeys) { NSString *valuesKey = [alertKeys isEqual:@"body"] ? @"alert" : valuesKey; - XCTAssertEqualObjects(values[valuesKey], aps[alertKey]); + XCTAssertEqualObjects([values objectForKey:valuesKey], + [aps objectForKey:alertKey]); } } else { - XCTAssertEqualObjects(values[@"alert"], aps[@"alert"]); + XCTAssertEqualObjects([values objectForKey:@"alert"], [aps objectForKey:@"alert"]); } - + } else if ([key isEqualToString:@"_od"]) { - XCTAssertEqualObjects(values[@"url"], notification[key]); - XCTAssertEqualObjects(values[@"type"], @"openDirect"); + XCTAssertEqualObjects([values objectForKey:@"url"], [notification objectForKey:key]); + XCTAssertEqualObjects([values objectForKey:@"type"], @"openDirect"); hadUrl = true; } else if ([key isEqualToString:@"_x"]) { - XCTAssertEqualObjects(values[@"url"], notification[key]); - XCTAssertEqualObjects(values[@"type"], @"cloudPage"); + XCTAssertEqualObjects([values objectForKey:@"url"], [notification objectForKey:key]); + XCTAssertEqualObjects([values objectForKey:@"type"], @"cloudPage"); hadUrl = true; } else { - XCTAssertEqualObjects(values[key], notification[key]); + XCTAssertEqualObjects([values objectForKey:key], [notification objectForKey:key]); } } - + if (!hadUrl) { - XCTAssertNil(values[@"url"]); - XCTAssertEqualObjects(values[@"type"], @"other"); + XCTAssertNil([values objectForKey:@"url"]); + XCTAssertEqualObjects([values objectForKey:@"type"], @"other"); } return YES; } diff --git a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/NSNotificationCenter+OCMAdditions.h b/tests/ios/MCCordovaPluginLib/usr/include/OCMock/NSNotificationCenter+OCMAdditions.h deleted file mode 100644 index 7d58aab..0000000 --- a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/NSNotificationCenter+OCMAdditions.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2009-2016 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - -@class OCObserverMockObject; - - -@interface NSNotificationCenter(OCMAdditions) - -- (void)addMockObserver:(OCObserverMockObject *)notificationObserver name:(NSString *)notificationName object:(id)notificationSender; - -@end diff --git a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMArg.h b/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMArg.h deleted file mode 100644 index 6df735e..0000000 --- a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMArg.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2009-2016 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - -@interface OCMArg : NSObject - -// constraining arguments - -+ (id)any; -+ (SEL)anySelector; -+ (void *)anyPointer; -+ (id __autoreleasing *)anyObjectRef; -+ (id)isNil; -+ (id)isNotNil; -+ (id)isEqual:(id)value; -+ (id)isNotEqual:(id)value; -+ (id)isKindOfClass:(Class)cls; -+ (id)checkWithSelector:(SEL)selector onObject:(id)anObject; -+ (id)checkWithBlock:(BOOL (^)(id obj))block; - -// manipulating arguments - -+ (id *)setTo:(id)value; -+ (void *)setToValue:(NSValue *)value; -+ (id)invokeBlock; -+ (id)invokeBlockWithArgs:(id)first,... NS_REQUIRES_NIL_TERMINATION; - -+ (id)defaultValue; - -// internal use only - -+ (id)resolveSpecialValues:(NSValue *)value; - -@end - -#define OCMOCK_ANY [OCMArg any] - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) - #define OCMOCK_VALUE(variable) \ - ({ __typeof__(variable) __v = (variable); [NSValue value:&__v withObjCType:@encode(__typeof__(__v))]; }) -#else - #define OCMOCK_VALUE(variable) [NSValue value:&variable withObjCType:@encode(__typeof__(variable))] -#endif - diff --git a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMConstraint.h b/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMConstraint.h deleted file mode 100644 index 19fc1a7..0000000 --- a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMConstraint.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2007-2016 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - - -@interface OCMConstraint : NSObject - -+ (instancetype)constraint; -- (BOOL)evaluate:(id)value; - -// if you are looking for any, isNil, etc, they have moved to OCMArg - -// try to use [OCMArg checkWith...] instead of the constraintWith... methods below - -+ (instancetype)constraintWithSelector:(SEL)aSelector onObject:(id)anObject; -+ (instancetype)constraintWithSelector:(SEL)aSelector onObject:(id)anObject withValue:(id)aValue; - - -@end - -@interface OCMAnyConstraint : OCMConstraint -@end - -@interface OCMIsNilConstraint : OCMConstraint -@end - -@interface OCMIsNotNilConstraint : OCMConstraint -@end - -@interface OCMIsNotEqualConstraint : OCMConstraint -{ - @public - id testValue; -} - -@end - -@interface OCMInvocationConstraint : OCMConstraint -{ - @public - NSInvocation *invocation; -} - -@end - -@interface OCMBlockConstraint : OCMConstraint -{ - BOOL (^block)(id); -} - -- (instancetype)initWithConstraintBlock:(BOOL (^)(id))block; - -@end - - -#define CONSTRAINT(aSelector) [OCMConstraint constraintWithSelector:aSelector onObject:self] -#define CONSTRAINTV(aSelector, aValue) [OCMConstraint constraintWithSelector:aSelector onObject:self withValue:(aValue)] diff --git a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMFunctions.h b/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMFunctions.h deleted file mode 100644 index b0c2df3..0000000 --- a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMFunctions.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2014-2016 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - - -#if defined(__cplusplus) -#define OCMOCK_EXTERN extern "C" -#else -#define OCMOCK_EXTERN extern -#endif - - -OCMOCK_EXTERN BOOL OCMIsObjectType(const char *objCType); diff --git a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMLocation.h b/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMLocation.h deleted file mode 100644 index 7870c52..0000000 --- a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMLocation.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2014-2016 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import -#import "OCMFunctions.h" - - -@interface OCMLocation : NSObject -{ - id testCase; - NSString *file; - NSUInteger line; -} - -+ (instancetype)locationWithTestCase:(id)aTestCase file:(NSString *)aFile line:(NSUInteger)aLine; - -- (instancetype)initWithTestCase:(id)aTestCase file:(NSString *)aFile line:(NSUInteger)aLine; - -- (id)testCase; -- (NSString *)file; -- (NSUInteger)line; - -@end - -OCMOCK_EXTERN OCMLocation *OCMMakeLocation(id testCase, const char *file, int line); diff --git a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMMacroState.h b/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMMacroState.h deleted file mode 100644 index dba41be..0000000 --- a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMMacroState.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2014-2016 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - -@class OCMLocation; -@class OCMRecorder; -@class OCMStubRecorder; -@class OCMockObject; - - -@interface OCMMacroState : NSObject -{ - OCMRecorder *recorder; -} - -+ (void)beginStubMacro; -+ (OCMStubRecorder *)endStubMacro; - -+ (void)beginExpectMacro; -+ (OCMStubRecorder *)endExpectMacro; - -+ (void)beginRejectMacro; -+ (OCMStubRecorder *)endRejectMacro; - -+ (void)beginVerifyMacroAtLocation:(OCMLocation *)aLocation; -+ (void)endVerifyMacro; - -+ (OCMMacroState *)globalState; - -- (OCMRecorder *)recorder; - -- (void)switchToClassMethod; - -@end diff --git a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMRecorder.h b/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMRecorder.h deleted file mode 100644 index 9670d08..0000000 --- a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMRecorder.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2014-2016 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - -@class OCMockObject; -@class OCMInvocationMatcher; - - -@interface OCMRecorder : NSProxy -{ - OCMockObject *mockObject; - OCMInvocationMatcher *invocationMatcher; -} - -- (instancetype)init; -- (instancetype)initWithMockObject:(OCMockObject *)aMockObject; - -- (void)setMockObject:(OCMockObject *)aMockObject; - -- (OCMInvocationMatcher *)invocationMatcher; - -- (id)classMethod; -- (id)ignoringNonObjectArgs; - -@end diff --git a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMStubRecorder.h b/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMStubRecorder.h deleted file mode 100644 index e32029f..0000000 --- a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMStubRecorder.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2004-2016 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import -#import -#import - -@interface OCMStubRecorder : OCMRecorder - -- (id)andReturn:(id)anObject; -- (id)andReturnValue:(NSValue *)aValue; -- (id)andThrow:(NSException *)anException; -- (id)andPost:(NSNotification *)aNotification; -- (id)andCall:(SEL)selector onObject:(id)anObject; -- (id)andDo:(void (^)(NSInvocation *invocation))block; -- (id)andForwardToRealObject; - -@end - - -@interface OCMStubRecorder (Properties) - -#define andReturn(aValue) _andReturn(({ \ - __typeof__(aValue) _val = (aValue); \ - NSValue *_nsval = [NSValue value:&_val withObjCType:@encode(__typeof__(_val))]; \ - if (OCMIsObjectType(@encode(__typeof(_val)))) { \ - objc_setAssociatedObject(_nsval, "OCMAssociatedBoxedValue", *(__unsafe_unretained id *) (void *) &_val, OBJC_ASSOCIATION_RETAIN); \ - } \ - _nsval; \ -})) -@property (nonatomic, readonly) OCMStubRecorder *(^ _andReturn)(NSValue *); - -#define andThrow(anException) _andThrow(anException) -@property (nonatomic, readonly) OCMStubRecorder *(^ _andThrow)(NSException *); - -#define andPost(aNotification) _andPost(aNotification) -@property (nonatomic, readonly) OCMStubRecorder *(^ _andPost)(NSNotification *); - -#define andCall(anObject, aSelector) _andCall(anObject, aSelector) -@property (nonatomic, readonly) OCMStubRecorder *(^ _andCall)(id, SEL); - -#define andDo(aBlock) _andDo(aBlock) -@property (nonatomic, readonly) OCMStubRecorder *(^ _andDo)(void (^)(NSInvocation *)); - -#define andForwardToRealObject() _andForwardToRealObject() -@property (nonatomic, readonly) OCMStubRecorder *(^ _andForwardToRealObject)(void); - -@end - - - diff --git a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMock.h b/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMock.h deleted file mode 100644 index 9d55813..0000000 --- a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMock.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2004-2016 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import -#import -#import -#import -#import -#import -#import -#import -#import - - -#define OCMClassMock(cls) [OCMockObject niceMockForClass:cls] - -#define OCMStrictClassMock(cls) [OCMockObject mockForClass:cls] - -#define OCMProtocolMock(protocol) [OCMockObject niceMockForProtocol:protocol] - -#define OCMStrictProtocolMock(protocol) [OCMockObject mockForProtocol:protocol] - -#define OCMPartialMock(obj) [OCMockObject partialMockForObject:obj] - -#define OCMObserverMock() [OCMockObject observerMock] - - -#define OCMStub(invocation) \ -({ \ - _OCMSilenceWarnings( \ - [OCMMacroState beginStubMacro]; \ - OCMStubRecorder *recorder = nil; \ - @try{ \ - invocation; \ - }@finally{ \ - recorder = [OCMMacroState endStubMacro]; \ - } \ - recorder; \ - ); \ -}) - -#define OCMExpect(invocation) \ -({ \ - _OCMSilenceWarnings( \ - [OCMMacroState beginExpectMacro]; \ - OCMStubRecorder *recorder = nil; \ - @try{ \ - invocation; \ - }@finally{ \ - recorder = [OCMMacroState endExpectMacro]; \ - } \ - recorder; \ - ); \ -}) - -#define OCMReject(invocation) \ -({ \ - _OCMSilenceWarnings( \ - [OCMMacroState beginRejectMacro]; \ - OCMStubRecorder *recorder = nil; \ - @try{ \ - invocation; \ - }@finally{ \ - recorder = [OCMMacroState endRejectMacro]; \ - } \ - recorder; \ - ); \ -}) - -#define ClassMethod(invocation) \ - _OCMSilenceWarnings( \ - [[OCMMacroState globalState] switchToClassMethod]; \ - invocation; \ - ); - - -#define OCMVerifyAll(mock) [mock verifyAtLocation:OCMMakeLocation(self, __FILE__, __LINE__)] - -#define OCMVerifyAllWithDelay(mock, delay) [mock verifyWithDelay:delay atLocation:OCMMakeLocation(self, __FILE__, __LINE__)] - -#define OCMVerify(invocation) \ -({ \ - _OCMSilenceWarnings( \ - [OCMMacroState beginVerifyMacroAtLocation:OCMMakeLocation(self, __FILE__, __LINE__)]; \ - @try{ \ - invocation; \ - }@finally{ \ - [OCMMacroState endVerifyMacro]; \ - } \ - ); \ -}) - -#define _OCMSilenceWarnings(macro) \ -({ \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wunused-value\"") \ - _Pragma("clang diagnostic ignored \"-Wunused-getter-return-value\"") \ - macro \ - _Pragma("clang diagnostic pop") \ -}) diff --git a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMockObject.h b/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMockObject.h deleted file mode 100644 index 31f7ac4..0000000 --- a/tests/ios/MCCordovaPluginLib/usr/include/OCMock/OCMockObject.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2004-2016 Erik Doernenburg and contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use these files except in compliance with the License. You may obtain - * a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ - -#import - -@class OCMLocation; -@class OCMInvocationStub; -@class OCMStubRecorder; -@class OCMInvocationMatcher; -@class OCMInvocationExpectation; - - -@interface OCMockObject : NSProxy -{ - BOOL isNice; - BOOL expectationOrderMatters; - NSMutableArray *stubs; - NSMutableArray *expectations; - NSMutableArray *exceptions; - NSMutableArray *invocations; -} - -+ (id)mockForClass:(Class)aClass; -+ (id)mockForProtocol:(Protocol *)aProtocol; -+ (id)partialMockForObject:(NSObject *)anObject; - -+ (id)niceMockForClass:(Class)aClass; -+ (id)niceMockForProtocol:(Protocol *)aProtocol; - -+ (id)observerMock; - -- (instancetype)init; - -- (void)setExpectationOrderMatters:(BOOL)flag; - -- (id)stub; -- (id)expect; -- (id)reject; - -- (id)verify; -- (id)verifyAtLocation:(OCMLocation *)location; - -- (void)verifyWithDelay:(NSTimeInterval)delay; -- (void)verifyWithDelay:(NSTimeInterval)delay atLocation:(OCMLocation *)location; - -- (void)stopMocking; - -// internal use only - -- (void)addStub:(OCMInvocationStub *)aStub; -- (void)addExpectation:(OCMInvocationExpectation *)anExpectation; - -- (BOOL)handleInvocation:(NSInvocation *)anInvocation; -- (void)handleUnRecordedInvocation:(NSInvocation *)anInvocation; -- (BOOL)handleSelector:(SEL)sel; - -- (void)verifyInvocation:(OCMInvocationMatcher *)matcher; -- (void)verifyInvocation:(OCMInvocationMatcher *)matcher atLocation:(OCMLocation *)location; - -@end - diff --git a/tests/ios/MCCordovaPluginLib/usr/lib/libOCMock.a b/tests/ios/MCCordovaPluginLib/usr/lib/libOCMock.a deleted file mode 100644 index a826ec3..0000000 Binary files a/tests/ios/MCCordovaPluginLib/usr/lib/libOCMock.a and /dev/null differ diff --git a/tests/ios/package.json b/tests/ios/package.json index fbd5b7e..9b02945 100644 --- a/tests/ios/package.json +++ b/tests/ios/package.json @@ -4,10 +4,8 @@ "description": "iOS Unit Tests for Marketing Cloud Plugin", "author": "Salesforce Marketing Cloud", "license": "BSD-3-Clause", - "dependencies": { - "cordova-ios": "*" - }, "scripts": { - "test": "xcodebuild -scheme CordovaLib && xcodebuild test -scheme MCCordovaPluginLib -destination 'platform=iOS Simulator,name=iPhone X'" + "install": "pod install --project-directory=MCCordovaPluginLib", + "test": "xcodebuild -workspace MCCordovaPluginLib/MCCordovaPluginLib.xcworkspace test -scheme Tests -destination 'platform=iOS Simulator,name=iPhone X'" } } diff --git a/www/MCCordovaPlugin.js b/www/MCCordovaPlugin.js index e85cff7..d869750 100644 --- a/www/MCCordovaPlugin.js +++ b/www/MCCordovaPlugin.js @@ -72,7 +72,7 @@ var MCCordovaPlugin = { * @param {function(enabled)} successCallback * @param {boolean} successCallback.enabled - Whether push is enabled. * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#isPushEnabled()|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#isPushEnabled()|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_pushEnabled|iOS Docs} */ isPushEnabled: function(successCallback, errorCallback) { @@ -84,7 +84,7 @@ var MCCordovaPlugin = { * Enables push messaging in the native Marketing Cloud SDK. * @param {function} [successCallback] * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#enablePush()|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#enablePush()|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_setPushEnabled:|iOS Docs} */ enablePush: function(successCallback = undefined, errorCallback = undefined) { @@ -96,7 +96,7 @@ var MCCordovaPlugin = { * Disables push messaging in the native Marketing Cloud SDK. * @param {function} [successCallback] * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#disablePush()|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#disablePush()|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_setPushEnabled:|iOS Docs} */ disablePush: function(successCallback, errorCallback) { @@ -111,7 +111,7 @@ var MCCordovaPlugin = { * @param {string} successCallback.token - The token used for push * messaging. * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#getPushToken()|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/messages/push/PushMessageManager.html#getPushToken()|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_deviceToken|iOS Docs} */ getSystemToken: function(successCallback, errorCallback) { @@ -125,7 +125,7 @@ var MCCordovaPlugin = { * @param {Object.} successCallback.attributes - The * key/value map of attributes set in the registration. * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.html#getAttributes()|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.html#getAttributes()|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_attributes|iOS Docs} */ getAttributes: function(successCallback, errorCallback) { @@ -142,7 +142,7 @@ var MCCordovaPlugin = { * @param {boolean} successCallback.saved - Whether the attribute value was * set in the registration. * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#setAttribute(java.lang.String,%20java.lang.String)|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#setAttribute(java.lang.String,%20java.lang.String)|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_setAttributeNamed:value:|iOS Docs} */ setAttribute: function(key, value, successCallback, errorCallback) { @@ -157,7 +157,7 @@ var MCCordovaPlugin = { * @param {boolean} successCallback.saved - Whether the value of the `key` * attribute was cleared from the registration. * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#clearAttribute(java.lang.String)|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#clearAttribute(java.lang.String)|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_clearAttributeNamed:|iOS Docs} */ clearAttribute: function(key, successCallback, errorCallback) { @@ -171,7 +171,7 @@ var MCCordovaPlugin = { * @param {boolean} successCallback.saved - Whether the value passed in for * `tag` was saved in the registration. * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#addTag(java.lang.String)|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#addTag(java.lang.String)|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_addTag:|iOS Docs} */ addTag: function(tag, successCallback, errorCallback) { @@ -185,7 +185,7 @@ var MCCordovaPlugin = { * @param {boolean} successCallback.saved - Whether the value passed in for * `tag` was cleared from the registration. * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#removeTag(java.lang.String)|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#removeTag(java.lang.String)|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_removeTag:|iOS Docs} */ removeTag: function(tag, successCallback, errorCallback) { @@ -198,7 +198,7 @@ var MCCordovaPlugin = { * @param {string[]} successCallback.tags - The array of tags currently set * in the native SDK. * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.html#getTags()|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.html#getTags()|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_tags|iOS Docs} */ getTags: function(successCallback, errorCallback) { @@ -213,7 +213,7 @@ var MCCordovaPlugin = { * @param {boolean} successCallback.saved - Whether the value passed in for * `contactKey` was saved in the registration. * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#setContactKey(java.lang.String)|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.Editor.html#setContactKey(java.lang.String)|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_setContactKey:|iOS Docs} */ setContactKey: function(contactKey, successCallback, errorCallback) { @@ -225,7 +225,7 @@ var MCCordovaPlugin = { * @param {function(contactKey)} successCallback * @param {string} successCallback.contactKey - The current contact key. * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.html#getContactKey()|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/registration/RegistrationManager.html#getContactKey()|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_contactKey|iOS Docs} */ getContactKey: function(successCallback, errorCallback) { @@ -236,7 +236,7 @@ var MCCordovaPlugin = { * Enables verbose logging within the native Marketing Cloud SDK. * @param {function} [successCallback] * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/MarketingCloudSdk.html#setLogLevel(int)|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/MarketingCloudSdk.html#setLogLevel(int)|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_setDebugLoggingEnabled:|iOS Docs} */ enableVerboseLogging: function(successCallback, errorCallback) { @@ -247,7 +247,7 @@ var MCCordovaPlugin = { * Disables verbose logging within the native Marketing Cloud SDK. * @param {function} [successCallback] * @param {function} [errorCallback] - * @see {@link https://salesforce-marketingcloud.github.io/JB4A-SDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/MarketingCloudSdk.html#setLogLevel(int)|Android Docs} + * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/6.0/reference/com/salesforce/marketingcloud/MarketingCloudSdk.html#setLogLevel(int)|Android Docs} * @see {@link https://salesforce-marketingcloud.github.io/MarketingCloudSDK-iOS/appledoc/Classes/MarketingCloudSDK.html#//api/name/sfmc_setDebugLoggingEnabled:|iOS Docs} */ disableVerboseLogging: function(successCallback, errorCallback) { @@ -290,13 +290,27 @@ var MCCordovaPlugin = { argsCheck.checkArgs('f', `${PLUGIN_NAME}.setOnUrlActionListener`, arguments); onUrlAction = urlActionListener; _exec(undefined, undefined, 'subscribe', ['urlAction']); - } + }, /** * @callback module:MCCordovaPlugin~urlActionCallback * @param {string} url - The url associated with the action taken by the user. */ + /** + * Instructs the native SDK to log the SDK state to the native logging system (Logcat for + * Android and Xcode/Console.app for iOS). This content can help diagnose most issues within + * the SDK and will be requested by the Marketing Cloud support team. + * + * @param {function} [successCallback] + * @param {function} [errorCallback] + * @since 6.3.1 + */ + logSdkState: function(successCallback, errorCallback) { + argsCheck.checkArgs('FF', `${PLUGIN_NAME}.logSdkState`, arguments); + _exec(successCallback, errorCallback, 'logSdkState'); + } + }; module.exports = MCCordovaPlugin;