MicroStrategy ONE

Embed a Report or Document in iOS

You can embed a MicroStrategy report or document in a third-party application, so that MicroStrategy data is displayed together with other non-MicroStrategy data.

The code snippets below illustrate how to embed a MicroStrategy document as one of three views that each take up part of the screen. The MicroStrategy view only displays data and does not include a toolbar for navigating the data that is displayed.

You declare a UIWebView to embed each source of non-MicroStrategy Web content in your application and a UIView for the rectangular area on the screen where the MicroStrategy document will be displayed. You declare two view controllers for the MicroStrategy view.

Copy
IBOutlet UIWebView* mPublicDataView;
IBOutlet UIWebView* mSecondPublicDataView;
IBOutlet UIView* mMicroStrategyView;
IBOutlet ExistingAppViewController* mMainVC;
IBOutlet MSTRObjectViewController* mMicroStrategyVC;

When the application finishes launching, it invokes the setupNavigationControllerWithApplicationLauncher method and loads the MicroStrategy view. After the view is loaded, you can do other initialization, but this is not illustrated in the code snippet below.

Copy
- (BOOL) application: (UIApplication*) application didFinishLaunchingWithOptions: (NSDictionary*) launchOptions {
   BOOL launchedOK = [super application: application didFinishLaunchingWithOptions: _launchOptions];
   [window addSubview: mMainVC.view];
   [window makeKeyAndVisible];
   ...
   return launchedOK;
}

You provide the setupNavigationControllerWithApplicationLauncher method. In this method, you add the code to set up the MicroStrategy view using the settings in ConnectionInfo.plist. You also point to a specific report or document.

Copy
- (void) setupNavigationControllerWithApplicationLauncher: (ApplicationLauncherController*) applicationLauncherController {
   [Generic setupConnectInfoFromPlist: @"ConnectionInfo.plist" ];
    mMicroStrategyVC.view = mMicroStrategyView;
    NSString* plistFilePath = [[NSBundle mainBundle] pathForResource:@"ConnectionInfo.plist" ofType:nil];
    NSDictionary* plistDict = [[NSDictionary alloc] initWithContentsOfFile:plistFilePath];
    NSString* objectID = [plistDict objectForKey:@"reportID"];
    NSString* objectType = [plistDict objectForKey:@"reportType"];
   // Point to a specific document
   if ([StringUtils string:[objectType uppercaseString] isEqualTo:@"REPORT"])
        [mMicroStrategyVC loadWithObjectID:objectID type:ObjectTypeReportDefinition];
   else if ([StringUtils string:[objectType uppercaseString] isEqualTo:@"DOCUMENT"])
        [mMicroStrategyVC loadWithObjectID:objectID type:ObjectTypeDocumentDefinition];
}

After the xib has finished loading, you send requests to load the web content in the two non-MicroStrategy views.

Copy
- (void) viewDidLoad {
   [super viewDidLoad];
    NSURL* publicDataURL = [NSURL URLWithString: @"http://www.motleyfool.idmanagedsolutions.com/charts/advanced/caps_advanced.chart?TIME_SPAN=3M&RESOLUTION=D&SYMBOL_US=BAC&ID_NOTATION=&IND_1=volume&CLOSE_LINE=0&TYPE=mountain&AVG1=&AXIS_SCALE=lin&ID_BENCH1=&ID_BENCH2=&IND_2=&IND_4="];
    NSUNSURLRequest* publicDataRequest = [NSURLRequest requestWithURL: publicDataURL];
   [mPublicDataView loadRequest: publicDataRequest ];
    publicDataURL = [NSURL URLWithString: @"http://bonds.yahoo.com/bonds_big.png"];
    publicDataRequest = [NSURLRequest requestWithURL: publicDataURL];
   [mSecondPmSecondPublicDataView loadRequest: publicDataRequest];
}

In order for touches to be handled correctly inside the MicroStrategy view, the window must be of class MSTRUIWindow instead of UIWindow. You can add code to check whether this is true and provide an alert if it is not.

Copy
- (UIWindow*) window {
   return [super window];
  }
- (void) setWindow: (UIWindow*) w {
   if (![w isKindOfClass: [MSTRUIWindow class]]) {
      NSLog( @"\n\n\nAny window containing MicroStrategy content should be of class MSTRUIWindow instead of UIWindow.\n"
      "This ensures that touches are handled correctly inside any MicroStrategy view.\n"
      "You typically edit the class of the window in Interface Builder.\n\n\n");
      return;
      }
      [super setWindow: w];
  }