HUA YU TSENG
1 min readApr 6, 2020

Different in Xcode 11

  1. didRegisterForRemoteNotificationsWithDeviceToken
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {    if (@available(iOS 13.0, *)) {  
NSString *token = [self stringFromDeviceToken:deviceToken];
NSLog(@"asdaa token: %@",token);
} else {
NSString *token = [[NSString stringWithFormat:@"%@", deviceToken] tokenString];
NSLog(@"asdaa token: %@",token);
}
}
- (NSString *)stringFromDeviceToken:(NSData *)deviceToken {
NSUInteger length = deviceToken.length;
if (length == 0) {
return nil;
}
const unsigned char *buffer = deviceToken.bytes;
NSMutableString *hexString = [NSMutableString stringWithCapacity:(length * 2)];
for (int i = 0; i < length; ++i) {
[hexString appendFormat:@"%02x", buffer[i]];
}
return [hexString copy];
}

2. Disable new Present style

@implementation UIViewController (Utilities)
void Swizzle(Class c, SEL orig, SEL new){ Method origMethod = class_getInstanceMethod(c, orig);
Method newMethod = class_getInstanceMethod(c, new);
if(class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod))) {
class_replaceMethod(c, new,
method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
} else {
method_exchangeImplementations(origMethod, newMethod);
}
}+ (void)load
{
SEL autoPresent = @selector(presentViewController:animated:completion:);
SEL fullPresent = @selector(swizzledPresent:animated:completion:); Swizzle(NSClassFromString(@"UIViewController"), autoPresent, fullPresent);}- (void)swizzledPresent:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion API_AVAILABLE(ios(5.0)) {if (@available(iOS 13.0, *)) { if (viewControllerToPresent.modalPresentationStyle ==
UIModalPresentationPageSheet ||
viewControllerToPresent.modalPresentationStyle ==
UIModalPresentationAutomatic) {
viewControllerToPresent.modalPresentationStyle =
UIModalPresentationFullScreen;
}}[self swizzledPresent:viewControllerToPresent animated:flag completion:completion];}

3. Disable Dark mode

if (@available(iOS 13.0, *)) {
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
}

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

HUA YU TSENG
HUA YU TSENG

Written by HUA YU TSENG

I am Red, an iOS developer, I have hands on experience in iOS, Flutter, familiar with RxSwift Moya Unit/UI testing and Gitlab-CI.

No responses yet

Write a response