-
-
Save shakemno/1f1cd973ea4316b310cc0c40a530b6d0 to your computer and use it in GitHub Desktop.
Dummy class easing detection whether the native StoreKit in-app Review alert has been fired or not. Useful as a callback when firing the limited system rating alert.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface SKStoreReviewDummyClass : NSObject @end | |
@implementation SKStoreReviewDummyClass | |
+ (void)load | |
{ | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
Class class = [self class]; | |
Class ratingClass = NSClassFromString(@"SKStoreReviewPresentationWindow"); | |
SEL originalSelector = @selector(init); | |
SEL swizzledSelector = @selector(xxx_init); | |
Method oldMethod = class_getInstanceMethod(ratingClass, originalSelector); | |
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); | |
class_addMethod(ratingClass, | |
swizzledSelector, | |
method_getImplementation(swizzledMethod), | |
method_getTypeEncoding(swizzledMethod)); | |
swizzledMethod = class_getInstanceMethod(ratingClass, swizzledSelector); | |
method_exchangeImplementations(oldMethod, swizzledMethod); | |
}); | |
} | |
- (instancetype)xxx_init | |
{ | |
NSLog(@"Star rating alert fired !!!!"); | |
return [self xxx_init]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment