IMQA GUIDE
HomepageFAQDeveloper forum
ENG
ENG
  • Getting started
    • Notice
    • Supported environment
  • Installation Guide
    • Android
      • Installing MPM SDK
      • Setting MPM SDK
      • Installing Crash SDK
      • Setting Crash SDK
    • iOS
      • Installing MPM SDK
      • Setting MPM SDK
      • Installing Crash SDK
      • Setting Crash SDK
    • React Native
      • Android
      • iOS
      • React Native Library
    • Cordova
      • Android
      • iOS
    • Morpheus
      • Android
      • iOS
    • W Hybrid
    • Web (WPM)
      • WebAgent Installation
      • WebAgent Setting
      • Browser Compatibility
  • User Guide
    • Using MPM
      • Project list
      • Performance Dashboard
      • A/B Dashboard
      • Screen performance analysis
      • Detailed performance analysis
      • UBA (User Behavior Analysis)
      • Region analysis
      • Statistics
      • Report
      • Alert
      • Management
    • Using Crash
      • Project list
      • Dashboard
      • Error details
      • Error search
      • Statistics
      • Settings
    • Using WPM
      • Project list
      • Performance Dashboard
      • Page performance analysis
      • Detailed performance analysis
      • Reverse Behavior Analysis
      • Statistics
      • Report
      • Alert
      • Management
    • Using WCrash
      • Project list
      • Dashboard
      • Error details
      • Error search
      • Statistics
Powered by GitBook
On this page
  • 1. Add Podfile
  • 2. Modify PPHybridViewController
  • Register WebView Agent
  1. Installation Guide
  2. Morpheus

iOS

Install SDK in Morpheus Environment

This document provides instructions on how to apply IMQA SDK in the React Native environment.

After applying the IMQA agent code with reference to the IMQA MPM Installation Guide, please follow further the instructions of this document.

1. Add Podfile

Write the following in your project Podfile.

pod 'IMQACrashAgent', '~> 3.24.1' 
pod 'IMQAMPMAgent', '~> 3.24.1'

2. Modify PPHybridViewController

Modify the viewWillAppear code and userContentController.

viewWillAppear
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSLog(@"PPHybridViewController viewWillAppear");
    [_poperaWebview.configuration.userContentController addScriptMessageHandler:self name:@"ImqaBridge"];
}
userContentController
- (void)userContentController:(nonnull WKUserContentController *)userContentController didReceiveScriptMessage:(nonnull WKScriptMessage *)message {
    if([message body]) {
        if([message.name isEqual: @"ImqaBridge"]) {
           [[IMQAMpm sharedInstance] saveWebviewPostMessage:self :message.body];
         }
        NSLog(@"[message body] = %@", [message body]);
        NSDictionary *dictJson;
        if([[message body] isKindOfClass:[NSDictionary class]]) {
            dictJson = [message body];
            
        } else {
            NSData *jsonData = [[message body] dataUsingEncoding:NSUTF8StringEncoding];
            //colors is a NSArray property used as dataSource of TableView
            dictJson = [NSJSONSerialization JSONObjectWithData:jsonData
                                                       options:NSJSONReadingMutableContainers
                                                       error:nil];
        }
    }
    else{
        NSLog(@"Invalid JavaScript request.");
    }
}

Register WebView Agent

Morpheus drops static files inside the mobile instead of fetching mobile pages from the server. Place the WebView agent for Morpheus we provide at the top of the head on all pages. Due to the structure of Morpheus, we recommend not using cdn but injecting the resources by yourself.

Last updated 1 year ago