All Products
Search
Document Center

Configure startup page

Last Updated: Aug 24, 2021

Startup-page advertisement is also known as splash advertisement. The startup page (also referred to the splash) shows after the app starts loading until the system notification of LaunchScreen ends. The startup page disappears when the home page appears.

After you configure the startup page on the client, you can configure the splash booth and advertising content on the console (See Create a booth and Create a marketing activity for details). The application will obtain and display booth delivery data based on the configuration, which realizes data dynamic delivery and display.

Note: Due to the asynchronous process of downloading delivery data, after configuring the delivery of the startup page, only the download operation is performed for the first time, the images are cached locally, in order not to block the launch of the application. And the cached images will be displayed the next time the application is started.

Based on the mPaaS framework, the timing and principle of the startup page are as follows. For details about the mPaaS framework, see mPaaS framework introduction.

  1. When the framework starts, the framework will create a bootloader to manage the main window of the application.
  2. When startup page appears, the framework will automatically switch the window, and return the created startup page window to the user.
  3. When the bootloader completes the startup and the micro application Launcher completes the display, the framework will close the startup page and switch back to the main window.

Prerequisites

Make sure that you have correctly started the CDP component. See Start component for details.

Procedures

In the framework classification file DTFrameworkInterface+MPCDPDemo_plugin.m generated by the mPaaS framework (as shown in the following figure), complete the following configuration.

  1. Declare a static variable to hold the window object of the startup page.
    1. static UIWindow *splashScreenWindow;
  2. In the application:handleDidFinishLaunchingWithOptions: method of the file, implement the startup page advertisement logic and open the startup page.

    1. - (DTFrameworkCallbackResult)application:(UIApplication *)application handleDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    2. // Advertisement logic.
    3. // Check if the startup page exists.
    4. BOOL showSplashWindow = YES;
    5. showSplashWindow = splashScreenExist(showSplashWindow);
    6. if (showSplashWindow) {
    7. __weak typeof(self) weakSelf = self;
    8. // Open the startup page.
    9. splashScreenWindow = APSplashScreenStart(^{
    10. // The callback for closing the startup page.
    11. [weakSelf splashScreenDidDismiss];
    12. });
    13. }
    14. return DTFrameworkCallbackResultContinue;
    15. }
  3. Implement the logic of startup page closing.
    This includes switching the main window of the application, releasing the startup page window, and sending a notification about closing the startup page. Note that the last operation is optional.

    1. - (void)splashScreenDidDismiss {
    2. // Restore the main window of the application as the key window.
    3. [DTContextGet().window makeKeyAndVisible];
    4. [self performSelector:@selector(doDismiss) withObject:nil afterDelay:0.0];
    5. }
    6. - (void)doDismiss {
    7. // Release the startup page object.
    8. splashScreenWindow.rootViewController = nil;
    9. splashScreenWindow = nil;
    10. [self notifySplashScreenDismiss];
    11. }
    12. - (void)notifySplashScreenDismiss {
    13. // Send a notification about splash screen clsoing. This operation is optional.
    14. [[NSNotificationCenter defaultCenter] postNotificationName:@"kSplashScreenDidDismiss" object:nil];
    15. }
  4. After the framework startup loading finishes, send a notification to the framework that startup page is about to close.
    We recommend that you call the notification method in the application:afterDidFinishLaunchingWithOptions: method.
    1. - (void)application:(UIApplication *)application afterDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    2. APWillKillSplashScreen();
    3. // ...
    4. }
  5. Send a notification after the home page ViewController starts, and the startup page is actually closed.
    ViewController is usually the rootViewController of the Launcher micro application. If the ViewController is a TabBarController, it is the ViewController where the first tab is located.

    1. @implementation HomeViewController
    2. - (void)viewDidLoad {
    3. [super viewDidLoad];
    4. }
    5. - (void)viewDidAppear:(BOOL)animated {
    6. [super viewDidAppear:animated];
    7. // Notify the Launcher that home page has been displayed.
    8. [[NSNotificationCenter defaultCenter] postNotificationName:@"kNotificationLauncherDidAppear" object:nil];
    9. }
    10. @end

For more information about the startup page APIs, see API description.