Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make HTTP Request from Custom Keyboard App Extension

My custom keyboard app extension is behaving differently on my real device, but fine on my iOS simulator.

I get the following errors on my real device

2017-02-17 16:30:01.369868 Custom Keyboard[8472:570942] [default] error registring notify port: (1000000)
2017-02-17 16:30:01.371652 Custom Keyboard[8472:570889] [Common] BKSAccelerometer unable to create notifyd token for device orientation
2017-02-17 16:30:01.702241 Custom Keyboard[8472:570940] [] __nwlog_err_simulate_crash_libsystem libsystem simulate crash failed "libsystem_network.dylib: networkd_settings_setup_notify_watch :: notify_register_dispatch(com.apple.system.networkd.settings) [status 1000000] failed"
2017-02-17 16:30:01.706023 Custom Keyboard[8472:570940] [] networkd_settings_setup_notify_watch notify_register_dispatch(com.apple.system.networkd.settings) [status 1000000] failed, dumping backtrace:

And I'm using standard Alamofire code:

Alamofire.request("https://httpbin.org/get").response { response in
    print("Request: \(response.request)")
    print("Response: \(response.response)")
    print("Error: \(response.error)")

    if let data = response.data, let utf8Text = String(data: data, encoding: .utf8) {
        print("Data: \(utf8Text)")
    }
}

I really don't understand what is going on here.

Any help appreciated. Thanks in advance.

like image 703
Jack Robson Avatar asked Sep 03 '26 09:09

Jack Robson


2 Answers

You need to have full-access to make your custom keyboard network-enabled.

Go to Info.plist, look inside the NSExtensionAttributes and change RequestsOpenAccess to YES.

Then when installing the keyboard on your iOS device, move the full access switch on.

like image 175
Jack Robson Avatar answered Sep 04 '26 22:09

Jack Robson


Go to Info.plist.

  1. Look inside "NSExtension -> NSExtensionAttributes -> RequestsOpenAccess to YES".

  2. You must add "App Transport Security Settings -> Allow Arbitrary Loads to YES".

Then,

  1. Go to Apple Settings, and select "General".

  2. Tap "Keyboard" and then "Keyboards".

  3. Tap "YourKeyboard", and then toggle the "Allow Full Access" switch.

  4. Press "Allow".

like image 22
said altintop Avatar answered Sep 04 '26 23:09

said altintop



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!