Forum Xamarin.iOS

NSItemProvider {Cannot load representation of type public.jpeg}

ph2000ph2000 Member ✭✭

I have a simple extension attempting to load a photo shared into my app. The app launches - but upon trying to LoadDataRepresentation - an 'error' {Cannot load representation of type public.jpeg} is returned - even though the code to check that the type is supported returns true - HasItemConformingTo..

Any ideas would be greatly appreciated. Thank you.

PS - Have already tried the same with calling the method 'item.LoadItem()...' same error is returned.

public override void DidSelectPost()
        {

            //Start processing
            foreach (NSExtensionItem extensionItem in this.ExtensionContext.InputItems)
                {
                foreach (NSItemProvider item in extensionItem.Attachments)
                {
                    string registeredItemType = item.RegisteredTypeIdentifiers[0].ToString();

                    if (item.HasItemConformingTo(registeredItemType))
                    {

                        item.LoadDataRepresentation(registeredItemType, (dataRaw, error) =>
                        {
                            var data = dataRaw;
                            DispatchQueue.MainQueue.DispatchSync(() =>
                             {
                                 if (data != null)
                                 {
                                     byte[] dataBytes = data.ToArray();
                                     ExtensionContext.CompleteRequest(null, null);
                                 }

                        });
                        });
                    }
                }

            }


        }
Sign In or Register to comment.