Friday, 11 September 2015

Sandboxing...


how can make app sandbox compliant? list of things i'm not sure whether okay or not are...

- calls ioreg , collects information on various devices (name, battery percent, whether it's charging, etc.,)
- makes nsstatusitem.
- stores bunch of data nsuserdefaults
- modifies whether launch item or not. code uses below:

code:
- (nsarray *)loginitems {     cfarrayref snapshotref = lssharedfilelistcopysnapshot(loginitemslistref, null);     return (__bridge nsarray *)snapshotref; }  // return cfretained item app's bundle, if there one. - (lssharedfilelistitemref)mainbundleloginitemcopy {     nsarray *loginitems = [self loginitems];     nsurl *bundleurl = [nsurl fileurlwithpath:[[nsbundle mainbundle] bundlepath]];          (id item in loginitems) {         lssharedfilelistitemref itemref = (__bridge lssharedfilelistitemref)item;         cfurlref itemurlref;                  if (lssharedfilelistitemresolve(itemref, 0, &itemurlref, null) == noerr) {             // again, use toll-free bridging.             nsurl *itemurl = (__bridge nsurl *)itemurlref;             if ([itemurl isequal:bundleurl])             {                 return (__bridge lssharedfilelistitemref)item;             }         }     }          return null; }  - (bool)launchonlogin {     if (!loginitemslistref)         return no;          lssharedfilelistitemref itemref = [self mainbundleloginitemcopy];         if (!itemref)         return no;          cfrelease(itemref);     return yes; }  - (void)setlaunchonlogin:(bool)value {     if (!loginitemslistref)         return;          if (!value) {         [self removemainbundlefromloginitems];     } else {         [self addmainbundletologinitems];     } }  - (void)addmainbundletologinitems {     // use url app (i.e. main bundle).     nsurl *bundleurl = [nsurl fileurlwithpath:[[nsbundle mainbundle] bundlepath]];          nsdictionary *properties;     properties = [nsdictionary dictionarywithobject:[nsnumber numberwithbool:yes] forkey:@"com.apple.loginitem.hideonlaunch"];          lssharedfilelistitemref itemref;     itemref = lssharedfilelistinsertitemurl(loginitemslistref,                                             klssharedfilelistitemlast,                                             null,                                             null,                                             (__bridge cfurlref)bundleurl,                                             (__bridge cfdictionaryref)properties,                                             null);     if (itemref) {         cfrelease(itemref);     } }  - (void)removemainbundlefromloginitems {     // try item corresponding main bundle url.     lssharedfilelistitemref itemref = [self mainbundleloginitemcopy];     if (!itemref)         return;          lssharedfilelistitemremove(loginitemslistref, itemref);          cfrelease(itemref); }
i guess should have more clear question: what, if anything, need make app sandbox compliant? there entitlements need give it? need use different apis? there part can't done sandboxing? (i fear may have give battery status final update next week , lie low , wait apple remove not being sandbox compliant.)
 

did read apple's extensive documentation?
https://developer.apple.com/devcenter/mac/app-sandbox/


these fine.

this won't work. have make user manually.

if have helper app want launch @ login, use smloginitemsetenabled().
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment