JonyFang / FFPopup

⛩ Presenting custom views as a popup in iOS.
MIT License
866 stars 56 forks source link

Google Admob #11

Closed dev-jw closed 4 years ago

dev-jw commented 5 years ago

When I use Google Admob, the pop can't show

JonyFang commented 5 years ago

Hi @SmallLion ,

Your problem description is a bit fuzzy. You can provide a demo project(demo repo link) and the steps to reproduce the issue, which will help us find the cause of the problem.

In addition, filling in the detailed description of the issue is also helpful.

cevanish12 commented 5 years ago

I noticed this issue as well. I believe admob adds a UIWindow to your app and my guess is that the popup is added to the wrong UIWindow. I managed to fix it by checking that the window is also the keyWindow when iterating through all the windows in the showWithParameters method.

dev-jw commented 5 years ago

@cevanish12 so, you solve it?

cevanish12 commented 5 years ago

Hey @JonyFang, sorry it took so long but I created a demo project at https://github.com/cevanish12/FFPopupAdmob. Basically the popup won't show if you set up interstitial ads on the viewcontroller you're presenting on. I managed to fix it on my personal projects by adding if (window.windowLevel == UIWindowLevelNormal && window.isKeyWindow) in the showWithParameters method. Hope this helps.

parkmino86 commented 5 years ago

I encountered the same issue.

parkmino86 commented 5 years ago

@cevanish12 's way is helpful to me.

FFPopup.m

Change the code. When Google AdMob is in my project, there are 2 different window here. the first thing is our original window, the second one is AdMob's. So, add FFPopupView to first window. Here is my change

if (!strongSelf.superview) {
                UIWindow *window = [[[UIApplication sharedApplication] windows] firstObject];
                if (window.windowLevel == UIWindowLevelNormal) {
                    [window addSubview:self];
                }
            }

...

fengong commented 4 years ago

image Hi @JonyFang , here are two way to resolve it

// 1. add to the target window before invoke show method
   // First, initial a pop up 
    FFPopup *popup = [FFPopup popupWithContentView:self];   
   //Add to you target window
    [[UIApplication sharedApplication].delegate.window addSubview:popup];
    // then show the popup
    [popup showWithLayout:FFPopupLayout_Center];

// 2. Modify source code in FFPopup.m file
 if (window.windowLevel == UIWindowLevelNormal && window.isHidden == NO) {
    [window addSubview:self];
    break;
}