Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Deploying application through MDM software and setting value on root.plist

EricTellerEricTeller Member ✭✭

When deploying our application through MDM software we are trying to set a default value on the root.plist. We have the value defined as shown in the attached file, "coding screen shot.png".


Attaching a second screen shot, "capture.png", of the setting on the ios device.

Is there anything special we have to do through xamarin to make this setting available so the MDM software can update it during the deployment?

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    We could change the value at runtime using NSUserDefaults:

    NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults;
    defaults.SetString("For test", "APFServerURL");
    

    APFServerURL is the key you set in the root plist.

  • EricTellerEricTeller Member ✭✭

    The scenario is that client A has 200 devices and when they deploy the software via MDM to those devices they would like to automatically set the setting to "myserver.test.com". Client B when they deploy via MDM to their 200 devices wants to set their setting to "myserver2.test.com".

  • LandLuLandLu Member, Xamarin Team Xamurai

    This could not be achieved.
    The files in the package could not be modified after deployed.
    However, you could indicate it through a fixed webservice and send a request when the application launches in the delegate:

    [Export ("application:didFinishLaunchingWithOptions:")]
    public bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
    {
        // Override point for customization after application launch.
        // If not required for your application you can safely delete this method
    
        Task.Run(async () =>
        {
            HttpClient client = new HttpClient();
            var response = await client.GetAsync("your server");
            var server = response.Content.ReadAsStringAsync();
    
            NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults;
            defaults.SetString(server, "APFServerURL");
        });
    
        return true;
    }
    

    Reset the value via a rest API and you could control this on the remote website.

  • EricTellerEricTeller Member ✭✭

    A bit more clarification on the scenario I described. Client A hosts their own servers. Client B hosts their own servers. At the point they run the application we have no idea the name of any server in their environment. And in many cases the clients do not allow any web calls outside their network.

  • LandLuLandLu Member, Xamarin Team Xamurai

    The root.plist in the package couldn't be modified.
    I'm afraid you have to reset its value and deploy it again.

Sign In or Register to comment.