Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 50 additions & 4 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,53 @@ jobs:
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
targetPlatform: ${{ matrix.targetPlatform }}
# - uses: actions/upload-artifact@v2
# with:
# name: Build-${{ matrix.targetPlatform }}
# path: build/${{ matrix.targetPlatform }}
buildAndroidSampleApp:
name: Build Android Sample app
needs: [pr-branch-check-name, pr-title-check, pr-branch-target-gitflow]
if: always() && !failure()
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v2
with:
fetch-depth: 0
lfs: true
- name: Setup Unity
uses: kuler90/setup-unity@v1
with:
unity-version: 2020.3.32f1
unity-modules: android
- name: Activate Unity
uses: kuler90/activate-unity@v1
with:
unity-username: ${{ secrets.UNITY_EMAIL }}
unity-password: ${{ secrets.UNITY_PASSWORD }}
unity-serial: ${{ secrets.UNITY_SERIAL }}
- name: "Build Android Sample app"
run: ./buildscript.sh; ./testAndroidBuild.sh
buildiOSSampleApp:
name: Build Android Sample app
needs: [pr-branch-check-name, pr-title-check, pr-branch-target-gitflow]
if: always() && !failure()
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v2
with:
fetch-depth: 0
lfs: true
- name: Setup Unity
uses: kuler90/setup-unity@v1
with:
unity-version: 2020.3.32f1
unity-modules: android
- name: Activate Unity
uses: kuler90/activate-unity@v1
with:
unity-username: ${{ secrets.UNITY_EMAIL }}
unity-password: ${{ secrets.UNITY_PASSWORD }}
unity-serial: ${{ secrets.UNITY_SERIAL }}
- name: "Build iOS Sample app"
run: ./buildscript.sh; ./testIOSBuild.sh


4 changes: 2 additions & 2 deletions Assets/mParticle/MParticleAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace mParticleAndroid
{
#if UNITY_ANDROID || UNITY_EDITOR
// #if UNITY_ANDROID || UNITY_EDITOR
public sealed class MParticleAndroid : IMParticleSDK
{
private AndroidJavaObject mp;
Expand Down Expand Up @@ -455,5 +455,5 @@ public IMParticleTask<IdentityApiResult> AddFailureListener(OnFailure listener)
}

}
#endif
// #endif
}
40 changes: 40 additions & 0 deletions TestMParticle/Assets/Editor/MParticleBuildPostprocessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

using UnityEditor;
using UnityEditor.Callbacks;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
using UnityEditor.iOS.Xcode.Extensions;
#endif

namespace mParticle
{
public class BuildPostProcessor
{
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget target, string path)
{
#if UNITY_IOS
if (target == BuildTarget.iOS)
{
// Get project into C#
var projectPath = PBXProject.GetPBXProjectPath(path);
var project = new PBXProject();
project.ReadFromFile(projectPath);

// Fix Xcode build settings
var projectGUID = project.ProjectGuid();
project.SetBuildProperty(projectGUID, "VALIDATE_WORKSPACE", "YES");
project.SetBuildProperty(projectGUID, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");

// Embed mParticle framework
var mainTargetGUID = project.GetUnityMainTargetGuid();
var frameworkFileGUID = project.FindFileGuidByProjectPath("Frameworks/Plugins/iOS/mParticle_Apple_SDK.framework");
project.AddFileToEmbedFrameworks(mainTargetGUID, frameworkFileGUID);

// Overwrite
project.WriteToFile(projectPath);
}
#endif
}
}
}
Binary file not shown.
Binary file not shown.
40 changes: 40 additions & 0 deletions TestMParticle/Assets/Plugins/iOS/mParticleUnity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef mParticle_mParticleUnity_h
#define mParticle_mParticleUnity_h

void _Initialize(const char *optionsJSON);
int _GetEnvironment(void *empty);
void _SetOptOut(int optOut);
void _SetUploadInterval(int uploadInterval);

void _LogEvent(const char *mpEvent);
void _LogCommerceEvent(const char *commerceEventJSON);
void _LogScreen(const char *screenName);
void _SetATTStatus(int status, double timestamp);

void _LeaveBreadcrumb(const char *breadcrumbName);

void _Upload(void);
void _Destroy(void);


char* _Identity_Identify(const char *identityApiRequestJSON);
char* _Identity_Login(const char *identityApiRequestJSON);
char* _Identity_Logout(const char *identityApiRequestJSON);
char* _Identity_Modify(const char *identityApiRequestJSON);

void _Identity_AddIdentityStateListener(void);
void _Identity_RemoveIdentityStateListener(void);

char* _Identity_GetCurrentUser(void);
char* _Identity_GetUser(const char *mpid);

char* _User_SetUserAttribute(const char *mpid, const char *key, const char *value);
char* _User_SetUserAttributes(const char *mpid, const char *attributesJSON);
char* _User_SetUserTag(const char *mpid, const char *tag);
char* _User_RemoveUserAttribute(const char *mpid, const char *key);
char* _User_GetUserAttributes(const char *mpid);

char* _User_GetUserIdentities(const char *mpid);
char* _User_GetCurrentUserMpid(const char *mpid);

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// FilteredMPIdentityApiRequest.h
//

#import <Foundation/Foundation.h>
#import "FilteredMParticleUser.h"

NS_ASSUME_NONNULL_BEGIN
@class MPIdentityApiRequest;

/**
A filtered version of the identity request object for sending to kits
*/
@interface FilteredMPIdentityApiRequest : NSObject

@property (nonatomic, strong, nullable, readonly) NSString *email;
@property (nonatomic, strong, nullable, readonly) NSString *customerId;
@property (nonatomic, strong, nullable, readonly) NSDictionary<NSNumber *, NSString *> *userIdentities;

- (instancetype)initWithIdentityRequest:(MPIdentityApiRequest *)request kitConfiguration:(MPKitConfiguration *)kitConfiguration;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// FilteredMParticleUser.h
//

#import <Foundation/Foundation.h>

@class MParticleUser;
@class MPKitConfiguration;

@interface FilteredMParticleUser : NSObject

@property(readonly, strong, nonnull) NSNumber *userId;

/**
Returns whether this user is currently logged in
*/
@property(readonly) BOOL isLoggedIn;

/**
Gets current user identities (readonly)
@returns A dictionary containing the collection of user identities
@see MPUserIdentity
*/
@property (readonly, strong, nonnull) NSDictionary<NSNumber *, NSString *> *userIdentities;

/**
Gets all user attributes.
@returns A dictionary containing the collection of user attributes.
*/
@property (readonly, strong, nonnull) NSDictionary<NSString *, id> *userAttributes;

- (instancetype _Nonnull )initWithMParticleUser:(MParticleUser *_Nonnull)user kitConfiguration:(MPKitConfiguration *_Nonnull)kitConfiguration;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// MPAliasRequest.h
//

#import <Foundation/Foundation.h>
#import "MParticleUser.h"

NS_ASSUME_NONNULL_BEGIN

/**
A request to copy data from one user to another, constrained to a particular time period.

Note that this request will not automatically copy user attributes to the destination user--this must be done manually, if desired.
*/
@interface MPAliasRequest : NSObject

/**
Creates a request specifying a source and destination user.

Alias start and end times will be automatically inferred based on the sourceUser's `firstSeen` and `lastSeen` properties.

If the first/last seen dates are earlier than the supported alias max time window, they will be adjusted automatically.

You can obtain user objects by indexing into the array returned by `[MParticle.sharedInstance.identity getAllUsers]` or by calling `[MParticle.sharedInstance.identity getUser:<MPID>]`.

Note that when using the latter method the user IDs must be known to the SDK or the call to `getUser:` will return nil.
*/
+ (MPAliasRequest *)requestWithSourceUser:(MParticleUser *)sourceUser destinationUser:(MParticleUser *)destinationUser;

/**
Creates a request specifying source and destination MPIDs and explicitly providing start and end times.

(MPID is also referred to as the `userId` property on `MParticleUser`.)

Unlike the above method, these dates will be sent to the server without adjusting them to take into account the alias max time window.

You can register a listener to get any errors that may be returned if the start/end times are outside the range accepted by the server. See `MPListenerController#onAliasRequestFinished:`.

Additionally, to support any potential advanced use cases, this method does not require MPIDs to be known to the SDK to perform the alias request.
*/
+ (MPAliasRequest *)requestWithSourceMPID:(NSNumber *)sourceMPID destinationMPID:(NSNumber *)destinationMPID startTime:(NSDate *)startTime endTime:(NSDate *)endTime;

/**
The MPID of the user that has existing data.
*/
@property (nonatomic, strong, readonly) NSNumber *sourceMPID;

/**
The MPID of the user that should receive the copied data.
*/
@property (nonatomic, strong, readonly) NSNumber *destinationMPID;

/**
The timestamp of the earliest data that should be copied, defaults to the source user's first seen timestamp.
*/
@property (nonatomic, strong, readonly) NSDate *startTime;

/**
The timestamp of the latest data that should be copied, defaults to the source user's last seen timestamp.
*/
@property (nonatomic, strong, readonly) NSDate *endTime;

/**
Whether the start/end times were automatically inferred from the source user's firstSeen and lastSeen properties
*/
@property (nonatomic, assign, readonly) BOOL usedFirstLastSeen;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// MPAliasResponse.h
//

#import <Foundation/Foundation.h>
#import "MPAliasRequest.h"

NS_ASSUME_NONNULL_BEGIN

/**
A response object representing the result of an alias request.
*/
@interface MPAliasResponse : NSObject

/**
The HTTP response code returned by the server.
*/
@property (nonatomic, assign) NSInteger responseCode;

/**
A human-readable error message returned by the server.
*/
@property (nonatomic, assign) NSString *errorResponse;

/**
The corresponding alias request for this response.
*/
@property (nonatomic, strong) MPAliasRequest *request;

/**
A random GUID associated with each alias request.
*/
@property (nonatomic, strong) NSString *requestID;

/**
Whether the SDK will automatically try to re-send the alias request.
*/
@property (nonatomic, assign) BOOL willRetry;

/**
Whether the alias request was successfully accepted by the server.
*/
@property (nonatomic, assign) BOOL isSuccessful;

@end

NS_ASSUME_NONNULL_END
Loading