@@ -528,9 +528,27 @@ - (void)application:(UIApplication *)p_application didReceiveRemoteNotification:
528528
529529- (void )application : (UIApplication*)p_application didRegisterForRemoteNotificationsWithDeviceToken : (NSData *)p_device_token
530530{
531- NSString *t_to_log = [NSString stringWithFormat: @" %s %@ %s " , " Application: push notification device token (" , p_device_token, " )" ];
532- NSString *t_registration_text = [NSString stringWithFormat: @" %@ " , p_device_token];
533-
531+ NSMutableString *t_registration_text = nil ;
532+ NSUInteger t_length = p_device_token.length ;
533+ const unsigned char *t_bytes = (const unsigned char *)p_device_token.bytes ;
534+ if (t_length != 0 )
535+ {
536+ t_registration_text = [[NSMutableString alloc ] init ];
537+ // Desired format: 8 segments of 8 letters/digits each, separated by spaces,
538+ // bracketed by <>
539+ [t_registration_text appendString: @" <" ];
540+ for (int i = 0 ; i < t_length; i++)
541+ {
542+ // %4 because each byte produces two chars
543+ if (i > 0 && i % 4 == 0 )
544+ {
545+ [t_registration_text appendString: @" " ];
546+ }
547+ [t_registration_text appendFormat: @" %02x " , t_bytes[i]];
548+ }
549+ [t_registration_text appendString: @" >" ];
550+ }
551+
534552 if (t_registration_text != nil )
535553 {
536554 MCAutoStringRef t_device_token;
@@ -543,21 +561,13 @@ - (void)application:(UIApplication*)p_application didRegisterForRemoteNotificati
543561 // If we are already active, dispatch.
544562 if (m_did_become_active)
545563 dispatch_notification_events ();
564+
565+ [t_registration_text release ];
546566 }
547-
548- /* if (t_registration_text != nil)
549- {
550- MCString t_device_token;
551- t_device_token.set ([t_registration_text cStringUsingEncoding:NSMacOSRomanStringEncoding], [t_registration_text length]);
552- m_device_token = t_device_token.clone();
553- MCLog("%s\n", [t_to_log cStringUsingEncoding: NSMacOSRomanStringEncoding]);
554- MCNotificationPostPushRegistered(m_device_token);
555- }*/
556567}
557568
558569- (void )application : (UIApplication*)p_application didFailToRegisterForRemoteNotificationsWithError : (NSError *)p_error
559570{
560- NSString *t_to_log = [NSString stringWithFormat: @" %s %@ %s " , " Application: push notification device token error (" , p_error, " )" ];
561571 NSString *t_error_text = [NSString stringWithFormat: @" %@ " , p_error];
562572
563573 // MW-2014-09-22: [[ Bug 13446 ]] Queue the event.
@@ -566,14 +576,6 @@ - (void)application:(UIApplication*)p_application didFailToRegisterForRemoteNoti
566576 // If we are already active, dispatch.
567577 if (m_did_become_active)
568578 dispatch_notification_events ();
569-
570- // if (t_error_text != nil)
571- // {
572- // MCAutoStringRef t_mc_error_text;
573- // /* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)t_error_text, &t_mc_error_text);
574- // MCLog("%s\n", [t_to_log cStringUsingEncoding: NSMacOSRomanStringEncoding]);
575- // MCNotificationPostPushRegistrationError(*t_mc_error_text);
576- // }
577579}
578580
579581// Check if we have received a custom URL
0 commit comments