I am working with custom keyboard extension. that almost done but i just facing issue with device when i communicate data with extension and my host app that not woking in device but same thing this working in simulator. My code is following:
HostApp View controller:
- (void)viewDidLoad {
_defaultvalue = [[NSUserDefaults alloc] initWithSuiteName:@"group.myapp.myappname.targetKeyboard"];
[_defaultvalue setBool:YES forKey:@"Layout"];
[_defaultvalue synchronize];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)RightAction:(id)sender {
_defaultvalue = [[NSUserDefaults alloc] initWithSuiteName:@"group.myapp.myappname.targetKeyboard"];
[_defaultvalue setBool:YES forKey:@"Layout"];
[_defaultvalue synchronize];
}
- (IBAction)leftAction:(id)sender {
_defaultvalue = [[NSUserDefaults alloc] initWithSuiteName:@"group.myapp.myappname.targetKeyboard"];
[_defaultvalue setBool:NO forKey:@"Layout"];
[_defaultvalue synchronize];
}
And i check this BOOL
value in my extension target using following code and change keyBoard layout according to my need:
-(void)LoadKeyboardview
{
_defaultvalue = [[NSUserDefaults alloc] initWithSuiteName:@"group.myapp.myappname.targetKeyboard"];
if([_defaultvalue boolForKey:@"Layout"])
{
self.ObjKeyLayout=[[[NSBundle mainBundle]loadNibNamed:@"keyboardLayout" owner:nil options:nil]objectAtIndex:0];
[self addGesturToKeyBoard];
self.inputView =self.ObjKeyLayout;
}
else{
self.ObjKeyLayout=[[[NSBundle mainBundle]loadNibNamed:@"leftLayout" owner:nil options:nil]objectAtIndex:0];
[self addGesturToKeyBoard];
self.inputView =self.ObjKeyLayout;
}
}
That same code working well in simulator ios8 device iPhone5. please is there any more code needed for this i read in apple doc that said NSUserDefaults
initWithSuiteName help me in this thank you.
UPDATE:
I have already set RequestsOpenAccess in plist and at setting->keyboard-customkeyboar->Full Access ON
My extention Plist: