iosmdmairwatch

How to restrict iOS App if user device is not enroll with Airwatch Agent?


In android we can easily check the device is enrolled or not as follow :

final boolean isEnrolled = awSDKManager.isEnrolled();
if (isEnrolled) {
      final String settings = awSDKManager.getCustomSettings();
}

There is similar function for iOS platform, By which we can check user device have AIRWatch agent application installed or enrolled with that.

Please guide me.


Solution

  • Firstly initialize AWController for the AIRWatch integration in

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
      AWController *controller = [AWController clientInstance];
    
      // 2) Defining the callback scheme so the app can get called back --
      // this should match the URL scheme you defined in "Callback Scheme Registration".
      controller.callbackScheme = @"awsdkcallback";
      controller.delegate = self;
      [controller start];
    
        return YES;
    }
    

    then use the following delegate method to check your device is enrolled or not

    - (void) initialCheckDoneWithError: (NSError *) error {
      if (error) {
        NSLog(@"Error in initialization: %@", [error localizedDescription]);
            NSLog(@"Not enrolled on AirWatch agent");
      } else {
        NSLog(@"Initialization completed without error");
      }
    

    }

    Update: for Latest AirWatch SDK 18, Use the following method for the same:

     [controller queryDeviceEnrollmentStatus:^(BOOL isSucess, NSError *error) {
    
        NSLog(@"Error is : %@",error.localizedDescription);
      }];