Monthly Archives: March 2017

Modifying the iPad/iPhone Mstr mobile app settings programatically

Hello there,

Today let’s talk about how to change the MicroStrategy Mobile app settings using Objective C. To do that you will have to use the latest XCode version and the latest MicroStrategy Mobile SDK version as well. Currently I used XCode 8.2.1 and MicroStrategy Mobile SDK 10.4

I had to modify the app to Offline Mode when the user is not connected to the VPN and I couldn’t the code to do that. So, to help you guys, here I’ll explain how to turn on/off the offline mode and how to change the other options too.

First things first.

Step 1: You have to create a custom app delegate class: https://lw.microstrategy.com/msdz/MSDL/104/docs/projects/MobileSDK/Default.htm#topics/iOS/iOS_Adding_Functionality_with_a_CustomApplDelegate.htm?Highlight=creating a custom

Step 2: Add the BooleanPreference.h file to the Custom Folder:

Just right click on the Custom folder and select “New File”and create a new header file. The name of the file must be BooleanPreference.h

Copy this content into this file:

#import <Foundation/Foundation.h>
@class MSIDevicePreferences;
@interface BooleanPreference : NSObject {
@private
    NSString* prefID;
    BOOL booleanValue;
    MSIDevicePreferences * __weak parent;
}
@property (nonatomic, copy) NSString* prefID;
@property (nonatomic) BOOL booleanValue;
-(BooleanPreference*)initWithID:(NSString*)_prefID boolValue:(BOOL)_value;
@end

Step 3: Your CustomAppDelegate.h must looks like this:

#import <UIKit/UIKit.h>
#import <MicrostrategyMobileSDK/MSIAppDelegateImpl.h>
#import <MicrostrategyMobileSDK/MSICommanderDelegate.h>
#import <MicrostrategyMobileSDK/MSIPreferencesStore.h>
#import <BooleanPreference.h>
@interface CustomAppDelegate : MSIAppDelegateImpl
@end

Step 4: Your CustomAppDelegate.m must looks like this:

#import “CustomAppDelegate.h”
@implementation CustomAppDelegate
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
BOOL res = [super application:application didFinishLaunchingWithOptions:launchOptions];
// Retrieve preferences
MSIPreferencesStore *store = [MSIPreferencesStore preferencesStore];
MSIDevicePreferences *dp= [store preferencesCopy];
BooleanPreference *boolPref = [dp getIsOfflineMode]; // Here, instead of using “getIsOfflineMode” you will be able to use the other possible options. Just remove it and start typing again and // XCode will show you the other options here
//Offline Mode on
boolPref.booleanValue = YES;
// Store new preferences
[store storePreferences:dp];
}
@end

That is it.

Hope it helps!

Just let me know if you need help with your code.

God bless you!