Ios8 Custom Keyboard - Copy & Paste to Uipasteboard

iOS8 Custom Keyboard - Copy & Paste to UIPasteboard

I was able to do it if I gave my custom keyboard "Full Access" in the Settings->General->Keyboard app.
You need to include "RequestsOpenAccess" = YES in your Info.plist file. AND you have to toggle "Full Access" on in the Settings app.

Seems like Apple is restricting access to the general UIPasteboard otherwise.

Determine if a copy to UIPasteboard was successful or not

I seem to have found a solution for now. This comes from the Apple Developer forums (user Andrew Boyd), and is the only post I could find that correctly solves the problem.

- (BOOL)testFullAccess
{
NSURL *containerURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"yourAppGroupID"]; // Need to setup in Xcode and Developer Portal
NSString *testFilePath = [[containerURL path] stringByAppendingPathComponent:@"testFullAccess"];

NSError *fileError = nil;
if ([[NSFileManager defaultManager] fileExistsAtPath:testFilePath]) {
[[NSFileManager defaultManager] removeItemAtPath:testFilePath error:&fileError];
}

if (fileError == nil) {
NSString *testString = @"testing, testing, 1, 2, 3...";
BOOL success = [[NSFileManager defaultManager] createFileAtPath:testFilePath
contents: [testString dataUsingEncoding:NSUTF8StringEncoding]
attributes:nil];
return success;
} else {
return NO;
}
}

In order for this to work, you must configure an app group, which your keyboard extension will use in an attempt to communicate with your keyboard app. To do this, follow Apple's instructions on Configuring App Groups. Use the identifier you create there to replace the string yourAppGroupID in the above code. Then this method will attempt to communicate with the main app for your keyboard. If successful, then we can conclude that Full Access is on.

I hope this solution helps someone else until Apple [hopefully] adds a quicker check if the user enabled Full Access or not. Not to mention, hopefully they create an easier way for the user to enable full access outside of the settings menu.

Custom Keyboard: How to Paste Image from pasteboard into messages.app MMS ios8

I haven't tried to create my own keyboard at the moment.

Nevertheless I use two keyboard on my iPhone that includes images.
Both of them ask the user to copy & paste the images into the message.

I might be wrong, but I guess this is an actual restriction.

Edit :

I can't find the documentation for that restriction.
However, here is a capture of PopKey Keyboard FAQ :

PopKey Restriction FAQ

iOS8 Custom Keyboard UIPasteBoard issue

After some headache and searching this was my solution.
Seems like an(other) iOS8 bug

  • Remove the container app + the keyboard
  • Reinstall the app + keyboard
  • Switch full access off + on at keyboard settings


Related Topics



Leave a reply



Submit