ios8 extension and container app how to share data

14,462

Solution 1

My solution is edit the Info.plist of my custom keyboard:

NSExtension -> NSExtensionAttributes -> RequestsOpenAccess

Make it YES.

Then delete the keyboard in your device and re-add it. In your keyboard add page you will find a setting named "Allow Full Access", enable it and the keyboard will access the shared data.

Solution 2

For keyboard extension, make sure enable RequestsOpenAccess as heheBear's answer
and try remove and add back keyboard from Setting/Keyoboard occasionally
keyboard extension is not stable and performance is really bad since beta 4, include beta 5

Solution 3

The problem only occurs for custom keyboard, and iOS8 beta 2 fixed the issue.

Share:
14,462
woof
Author by

woof

Updated on July 29, 2022

Comments

  • woof
    woof almost 2 years

    I'm having trouble to share data between iOS 8 extension and container app. I set up the group from develop portal and Xcode, and my entitlements plist both look like:

    <dict>
        <key>com.apple.security.application-groups</key>
        <array>
            <string>my group id</string>
        </array>
    </dict>
    

    The suggested solution in apple document to use [[NSUserDefaults standardUserDefaults]

    doesn't work for me.

    I've tried the solution by @Santa Claus from this post Communicating and persisting data between apps with App Groups to use

    [[NSUserDefaults alloc] initWithSuiteName:@"<group identifier>"];
    

    Santa Claus's solution worked on simulator but not on my iPhone 4s, any ideas on how to make it work on real device? Or am I missing anything?

    Some updates:

    [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"group id"];
    

    function returns url, and both urls from container app and extension look the same, as "path /private/var/mobile/Containers/Shared/AppGroup/3DFB9750-A9F3-4C37-BC3C-0D5BF746B‌​233". I created a json file inside that folder from container app but extension can't find any file in the folder when I run on device. But in simulator it finds it well and everything works.

  • iOS Dev
    iOS Dev almost 10 years
    iOS 8 beta 5 still does not work on real device, only on simulator
  • Ethan Long
    Ethan Long almost 10 years
    Looks like iOS GM sill having this issue, working on simulators but no device!
  • Nitin Gohel
    Nitin Gohel over 9 years
    working in simulator but same thing not working in device any idea why?
  • dvkch
    dvkch over 9 years
    nice!! it took me so long to find what it wasn't working... would you know of a way to detect the setting value from the extension?
  • MAC
    MAC over 9 years
    @heheBear this works for me on Simulator but not on real device any suggestion ?
  • Ravi Ojha
    Ravi Ojha about 9 years
    in my case (Sharing extension) is not working, i have added it in plist but not show on real device ,only work on simulators