|
|
@@ -33,9 +33,16 @@
|
|
|
|
|
|
- (void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)options {
|
|
|
// Register even on configuration failure so JS receives a useful error instead of timing out.
|
|
|
- [[JsbBridgeWrapper sharedInstance] addScriptEventListener:@"facebook.request" listener:^(NSString *payload) {
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{ [self handlePayload:payload]; });
|
|
|
- }];
|
|
|
+ // Creator 3.8.8's MRC bridge releases the listener after adding it to its array.
|
|
|
+ // Keep this outer block capture-free (no self or local variables): a global block
|
|
|
+ // has static lifetime and is safe with that ownership behavior. GCD owns the
|
|
|
+ // inner block and retains its payload until the main-queue callback runs.
|
|
|
+ static OnScriptEventListener const requestListener = ^(NSString *payload) {
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ [[FBWrapper shared] handlePayload:payload];
|
|
|
+ });
|
|
|
+ };
|
|
|
+ [[JsbBridgeWrapper sharedInstance] addScriptEventListener:@"facebook.request" listener:requestListener];
|
|
|
NSDictionary *info = NSBundle.mainBundle.infoDictionary;
|
|
|
if (![info[@"FacebookAppID"] isKindOfClass:NSString.class] || ![info[@"FacebookAppID"] length] ||
|
|
|
![info[@"FacebookClientToken"] isKindOfClass:NSString.class] || ![info[@"FacebookClientToken"] length]) {
|