diff --git a/Repro.embeddedframework/Repro.framework/Headers/Repro.h b/Repro.embeddedframework/Repro.framework/Headers/Repro.h index 46e15f3..573b2a8 100644 --- a/Repro.embeddedframework/Repro.framework/Headers/Repro.h +++ b/Repro.embeddedframework/Repro.framework/Headers/Repro.h @@ -31,8 +31,10 @@ typedef NS_ENUM(NSInteger, RPRLogLevel) { + (void)setUserID:(NSString *)userID; + (NSString *)getUserID; + (NSString *)getDeviceID; -+ (void)setUserProfile:(NSString *)value forKey:(NSString *)key; -+ (void)setUserProfile:(NSDictionary *)profile; ++ (void)setStringUserProfile:(NSString*)value forKey:(NSString*)key; ++ (void)setIntUserProfile:(int)value forKey:(NSString*)key; ++ (void)setDoubleUserProfile:(double)value forKey:(NSString*)key; ++ (void)setDateUserProfile:(NSDate*)value forKey:(NSString*)key; // Event tracking + (void)track:(NSString*)name properties:(NSDictionary*)properties; diff --git a/Repro.embeddedframework/Repro.framework/Info.plist b/Repro.embeddedframework/Repro.framework/Info.plist index b1107fc..57ee0ab 100644 Binary files a/Repro.embeddedframework/Repro.framework/Info.plist and b/Repro.embeddedframework/Repro.framework/Info.plist differ diff --git a/Repro.embeddedframework/Repro.framework/Repro b/Repro.embeddedframework/Repro.framework/Repro index 0613004..7be43c4 100644 Binary files a/Repro.embeddedframework/Repro.framework/Repro and b/Repro.embeddedframework/Repro.framework/Repro differ diff --git a/Repro.embeddedframework/Repro.framework/ReproSDKResources.bundle/Info.plist b/Repro.embeddedframework/Repro.framework/ReproSDKResources.bundle/Info.plist index b04499d..fbfb323 100644 Binary files a/Repro.embeddedframework/Repro.framework/ReproSDKResources.bundle/Info.plist and b/Repro.embeddedframework/Repro.framework/ReproSDKResources.bundle/Info.plist differ diff --git a/Repro.embeddedframework/Resources/ReproSDKResources.bundle/Info.plist b/Repro.embeddedframework/Resources/ReproSDKResources.bundle/Info.plist index b04499d..fbfb323 100644 Binary files a/Repro.embeddedframework/Resources/ReproSDKResources.bundle/Info.plist and b/Repro.embeddedframework/Resources/ReproSDKResources.bundle/Info.plist differ diff --git a/cpp/ReproCpp.h b/cpp/ReproCpp.h index 1322ee0..381e775 100644 --- a/cpp/ReproCpp.h +++ b/cpp/ReproCpp.h @@ -10,9 +10,7 @@ #include #include - -using std::string; -using std::map; +#include class ReproCpp { @@ -36,8 +34,12 @@ class ReproCpp { // User Profile static void setUserID(const char* userId); - static void setUserProfile(const char* key, const char* value); - static void setUserProfile(const std::map &profile); + static const char* getUserID(); + static const char* getDeviceID(); + static void setStringUserProfile(const char* key, const char* value); + static void setIntUserProfile(const char* key, int value); + static void setDoubleUserProfile(const char* key, double value); + static void setDateUserProfile(const char* key, std::time_t value); // Event Tracking static void track(const char*eventName); diff --git a/cpp/ReproCpp.mm b/cpp/ReproCpp.mm index 9d42011..6a71909 100644 --- a/cpp/ReproCpp.mm +++ b/cpp/ReproCpp.mm @@ -16,6 +16,17 @@ } } +static const char* convertNSStringToCString(NSString* string) { + if (string) { + const char* src = [string UTF8String]; + char* dst = (char*)malloc(strlen(src) + 1); + strcpy(dst, src); + return dst; + } else { + return ""; + } +} + static NSDictionary* convertCStringJSONToNSDictionary(const char* string) { if (string) { NSString* json = convertCStringToNSString(string); @@ -72,19 +83,28 @@ [Repro setUserID:convertCStringToNSString(userId)]; } -void ReproCpp::setUserProfile(const char* key, const char* value) { - [Repro setUserProfile:convertCStringToNSString(value) forKey:convertCStringToNSString(key)]; +const char* ReproCpp::getUserID() { + return convertNSStringToCString([Repro getUserID]); } -void ReproCpp::setUserProfile(const std::map &profile) { - std::map::const_iterator iter; - NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; - for (iter = profile.begin(); iter != profile.end(); iter++) { - NSString *key = [NSString stringWithUTF8String:iter->first.c_str()]; - NSString *value = [NSString stringWithUTF8String:iter->second.c_str()]; - dict[key] = value; - } - [Repro setUserProfile:[NSDictionary dictionaryWithDictionary:dict]]; +const char* ReproCpp::getDeviceID() { + return convertNSStringToCString([Repro getDeviceID]); +} + +void ReproCpp::setStringUserProfile(const char* key, const char* value) { + [Repro setStringUserProfile:convertCStringToNSString(value) forKey:convertCStringToNSString(key)]; +} + +void ReproCpp::setIntUserProfile(const char* key, int value) { + [Repro setIntUserProfile:value forKey:convertCStringToNSString(key)]; +} + +void ReproCpp::setDoubleUserProfile(const char* key, double value) { + [Repro setDoubleUserProfile:value forKey:convertCStringToNSString(key)]; +} + +void ReproCpp::setDateUserProfile(const char* key, std::time_t value) { + [Repro setDateUserProfile:[NSDate dateWithTimeIntervalSince1970:value] forKey:convertCStringToNSString(key)]; } void ReproCpp::track(const char* eventName) {