Last active
November 22, 2020 18:13
-
-
Save username0x0a/bd3f7228bab7230ab926165fd126e77a 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 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 |
Same question here. Did Apple approve that?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Has Apple approved this usage in your app? Any risk of app rejection?