mardi 17 janvier 2017

iOS app build with Adobe AIR SDK 24 crashes when trying to use permissions

I have an adobe AIR app developed for iOS devices and I use Adobe Flash Builder 4.7 to create the .ipa file.

Up to version 23 of the AIR SDK the app was working fine. With version 24 of the AIR SDK a Permissions class was added when trying to access the device camera. And now one should programmatically handle the permissions when accessing the camera as follows: http://ift.tt/2hk5d6j

I have tried implementing the given example in my codebase, and in the following snippet, I have null references to the permissions as follows:

   if (Camera.permissionStatus/*permissionStatus is null*/ != PermissionStatus.GRANTED)
   {       
                  cam.addEventListener(PermissionEvent.PERMISSION_STATUS,
                    function(e:PermissionEvent):void {
                        if (e.status == PermissionStatus.GRANTED)
                        {
                            connectCamera();
                        }
                        else
                        {
                            // permission denied
                        }
                    });

                try {
                    cam.requestPermission(); // **when calling this one my app crashes**
                } catch(e:Error)
                {
                    // another request is in progress
                }
            }
            else
            {
                connectCamera();
            }
        }
    }

    private function connectCamera():void
    {
        video = new Video(640, 480);
        video.attachCamera(cam);
        addChild(video);
    }

My hunch is that when debugging on the device the Flash Builder is using the flex sdk instead of the AIR SDK which makes the aforementioned properties/methods unavailable as stated in the SDK documentation: http://ift.tt/1ENbsXs where one can see that the permissionStatus method is only available for the AIR runtime.

Therefore, how can I check and make sure that I am debugging using the AIR runtime and eventually avoid my app to crash when asking the user for camera permissions.

Aucun commentaire:

Enregistrer un commentaire