1 min readApr 6, 2020
Different in Xcode 11
- 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;
}