Recently, the company has a demand to add the launch page advertisement. After checking a lot of information, there are basically two opinions. One is to display ads in real time, and the other is to save and display local ads next time. As for these two statements, a careful study, there are some advantages, but also some minor disadvantages. Let’s discuss it with you slowly.

1. Download the plan first and then show it

Here’s the solution I used: the first time the APP launches, the boot page loads, and then it goes to the home page, and for the first time it doesn’t show the launch page ads. Can choose in didFinishLaunchingWithOptions, advertising network request first, to determine the local have already stored the same advertising information, if it is, is not ignored. If no, the device is stored locally.

And so on the next time come in, can judge whether there is local storage of advertising information, there is a direct display, not directly into the home page.

Advantages: The startup process is smooth and does not affect user startup experience.

Cons: Ads aren’t real-time. For example, local ads have been removed, this time to start loading local is not a problem. For this point, I think it still depends on the actual operation of the company to determine, if there is a period of validity of background return, can avoid this situation.

On second thought, it doesn’t matter, and the impact is not very big. It feels good to do it that way.

2. Display solutions in real time

This scheme, studied, is also a good approach. APP launches, requests ads directly online, and we jump directly to the AD page, which is also divided into two situations.

In one case, first load local fixed advertising, advertising data within 1S return, countdown starts, direct display advertising, no advertising, or network request failure, directly end the countdown, enter the home page.

Another situation, and said at the beginning of the first download after display a little similar, at this time is to load the local download of the AD, advertising data within 1S back, countdown to open, direct display of the AD, and the AD download to the local. If the network request fails, countdown local download ads, if there is no advertising, but also directly end the countdown, enter the home page.

Pros: Update launch ads in real time to ensure they are up to date each time.

Cons: Ads can be delayed and user experience can be poor.

Still thought next, feel actually ok, want to see an attention dot after all where. As for user experience, for me, it would be better to go directly to the home page without showing the countdown. But since there’s this launch page thing, I think it’s ok to show it, not too often, not every time you open it. It’s just a small wish of mine.

3. Multiple Windows implementations

There are two ways to implement this launch advertising function, one of which is to use multiple Windows to achieve.

We in didFinishLaunchingWithOptions, first add two Windows.

Self. Window = UIWindow(frame: uiscreen.main.bounds) self. Window? .tintColor = .darkGray; let nav1 = UINavigationController(rootViewController: ViewController()) window? .rootViewController = nav1 window? .makeKeyAndVisible() // self.splashWindow = UIWindow(frame: CGRect(x: 0, y: 100, width: 300, height: 500)) self.splashWindow = UIWindow(frame: UIScreen.main.bounds) let splashVC = SplashViewViewController() let nav = UINavigationController(rootViewController: splashVC) splashWindow? .rootViewController = nav splashWindow? .makeKeyAndVisible()Copy the code

SplashWindow is for displaying the ads, Window is for displaying the home page, window is under splashWindow, so the top one we see first is for displaying the ads, and the nice thing about this is that while counting down the ads, the home page is actually asking for the page to load, and when the countdown is over, At this time the home page has also been loaded.

4. Single-window implementation

So if we’re just looking at a single window, we’re just looking at which page rootViewController is, and we’re just going to go from the AD page to the home page. The only thing to notice here is the transition animation. Here is how you want to see the effect.

This single-window usage, we often have the login page, home page switch, and boot page and home page switch, and so on, is not difficult to implement. I’m going to talk about it.

5. Rendering

GitHubDemo: github.com/wenweijia/S…

6. Summary

I put forward two schemes, both of which are text ones, which really sound literary. I originally wanted to make a flow chart, but I was a little lazy and busy. I will make it later when I have time

I want to see your opinions, such as whether there is a better plan or which plan needs to be improved. Please pay attention to it. Thank you!