Skip to content

Instantly share code, notes, and snippets.

@username0x0a
Last active November 22, 2020 18:13
Show Gist options
  • Save username0x0a/bd3f7228bab7230ab926165fd126e77a to your computer and use it in GitHub Desktop.
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.
@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
@satheeshwaran
Copy link

Has Apple approved this usage in your app? Any risk of app rejection?

@mlostekk
Copy link

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