@@ -43,6 +43,7 @@ - (void)didReceiveRemoteNotification:(NSDictionary *)userInfo
4343 withAction : (NSString *)action
4444 fetchCompletionHandler : (LeanplumFetchCompletionBlock)completionHandler ;
4545- (void )leanplum_application : (UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken : (NSData *)deviceToken ;
46+ - (NSString *)hexadecimalStringFromData : (NSData *)data ;
4647@end
4748
4849@interface LPActionManagerTest : XCTestCase
@@ -309,6 +310,14 @@ - (void)test_active_period_true
309310
310311}
311312
313+ -(void )testHexadecimalStringFromData {
314+ LPActionManager *manager = [[LPActionManager alloc ] init ];
315+ NSString *testString = @" 74657374537472696e67" ;
316+ NSData *data = [self hexDataFromString: testString];
317+ NSString *parsedString = [manager hexadecimalStringFromData: data];
318+ XCTAssertEqualObjects (testString, parsedString);
319+ }
320+
312321#pragma mark Helpers
313322
314323-(NSDictionary *)messageConfigInActivePeriod : (BOOL )inActivePeriod
@@ -324,4 +333,22 @@ -(NSDictionary *)messageConfigInActivePeriod:(BOOL)inActivePeriod
324333 };
325334 return config;
326335}
336+
337+ -(NSMutableData *)hexDataFromString : (NSString *)string {
338+
339+ NSMutableData *hexData= [[NSMutableData alloc ] init ];
340+ unsigned char whole_byte;
341+ char byte_chars[3 ] = {' \0 ' ,' \0 ' ,' \0 ' };
342+ int i;
343+ for (i=0 ; i < [string length ]/2 ; i++) {
344+ byte_chars[0 ] = [string characterAtIndex: i*2 ];
345+ byte_chars[1 ] = [string characterAtIndex: i*2 +1 ];
346+ whole_byte = strtol (byte_chars, NULL , 16 );
347+ [hexData appendBytes: &whole_byte length: 1 ];
348+ }
349+ return hexData;
350+ }
351+
352+
353+
327354@end
0 commit comments