Add the following method in the AppDelegate class, just before @end:

Finally, complete the setMethodCallHandler() method added earlier.
You need to handle a single platform method, getBatteryLevel(),
so test for that in the call argument. The implementation of
this platform method calls the iOS code written in the previous step,
and returns a response for both the success and error cases using
the result argument. If an unknown method is called, report that instead.

int

getBatteryLevel

UIDevice

device

UIDevice

currentDevice

device

batteryMonitoringEnabled

YES

if

device

batteryState

==

UIDeviceBatteryStateUnknown

return

else

return

int

)(