Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18852] Ti.App.iOS.UserDefaults needs ability to set the suiteName in order for it to work with Apple Watch

GitHub Issuen/a
TypeImprovement
PriorityHigh
StatusClosed
ResolutionInvalid
Resolution Date2015-04-25T01:13:08.000+0000
Affected Version/sn/a
Fix Version/sRelease 4.0.0
ComponentsTiAPI
Labelsn/a
ReporterRick Blalock
AssigneeIngo Muschenetz
Created2015-04-24T21:19:55.000+0000
Updated2018-10-22T14:00:32.000+0000

Description

I was looking at the new UserDefaults API we have for sharing data between iOS extensions and it's missing the ability to specify a suiteName. Without this, this API cannot share data across extensions. Example in a watch extension:
let sampleDefaults = NSUserDefaults(suiteName: "group.com.myapp.here")
Currently you can only do something like:
		Ti.App.iOS.UserDefaults.setObject('myKey', {});
Which points to the standard user defaults...which the apple watch can't access. Maybe a 3rd param needs to be introduced in these methods where you can specify the suiteName. Ref. http://stackoverflow.com/questions/27007288/watchkit-sdk-not-retrieving-data-from-nsuserdefaults

Comments

  1. Rick Blalock 2015-04-25

    Apparently, setting the suiteName is possible (though I didn't see reference to it at all in the class). Ref. https://github.com/appcelerator/titanium_mobile/blob/19886c8797a808d5cc4f572e85c791ac757a2c47/apidoc/Titanium/App/iOS/UserDefaults.yml
  2. Alberto Marcone 2018-10-22

    how do you actually use it? I need to retrieve the value passed from an MDM like this:
       NSString *value = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"com.apple.configuration.managed"] objectForKey:@"key"];
       

JSON Source