All Products
Search
Document Center

Mobile Platform as a Service:Configure startup page

Last Updated:Oct 20, 2023

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.

        static UIWindow *splashScreenWindow;
  2. In the application:handleDidFinishLaunchingWithOptions: method of the file, implement the startup page advertisement logic and open the startup page.

        - (DTFrameworkCallbackResult)application:(UIApplication *)application handleDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
            // Advertisement logic.
          // Check if the startup page exists.
            BOOL showSplashWindow = YES;
          showSplashWindow = splashScreenExist(showSplashWindow);
            if (showSplashWindow) {
                __weak typeof(self) weakSelf = self;
            // Open the startup page.
                splashScreenWindow = APSplashScreenStart(^{
                // The callback for closing the startup page.
                    [weakSelf splashScreenDidDismiss];
                });
            }
    
            return DTFrameworkCallbackResultContinue;
        }
  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.

        - (void)splashScreenDidDismiss {
            // Restore the main window of the application as the key window.
            [DTContextGet().window makeKeyAndVisible];
            [self performSelector:@selector(doDismiss) withObject:nil afterDelay:0.0];
        }
    
        - (void)doDismiss {
            // Release the startup page object.
            splashScreenWindow.rootViewController = nil;
            splashScreenWindow = nil;
            [self notifySplashScreenDismiss];
        }
    
        - (void)notifySplashScreenDismiss {
            // Send a notification about splash screen closing. This operation is optional.
            [[NSNotificationCenter defaultCenter] postNotificationName:@"kSplashScreenDidDismiss" object:nil];
        }
  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.

        - (void)application:(UIApplication *)application afterDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
            APWillKillSplashScreen();
          // ...
        }
  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.

        @implementation HomeViewController
    
        - (void)viewDidLoad {
            [super viewDidLoad];
        }
    
        - (void)viewDidAppear:(BOOL)animated {
            [super viewDidAppear:animated];
            // Notify the Launcher that home page has been displayed.
            [[NSNotificationCenter defaultCenter] postNotificationName:@"kNotificationLauncherDidAppear" object:nil];
        }
        @end

Related links

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