Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

I can't get the url of the shared extension (Physical device)

danielparedes97danielparedes97 Member ✭✭✭

I can get the url of the shared extension thanks to AppGroups thanks to my first question (https://forums.xamarin.com/discussion/comment/406402#Comment_406402)

The problem comes when I try to do the same with a physical device or iphone, I can't extract the url.

var appdef = new NSUserDefaults("group.com.xamarin.beambassador", NSUserDefaultsType.SuiteName);
var key = appdef.StringForKey("appdef");
return key;

Key is empty, and I send the url with the next code:

var urlstr = string.Empty;
            var item = ExtensionContext.InputItems[0];
            NSItemProvider prov = null;


            if (item != null)
                prov = item.Attachments[0];
            try
            {
                if (prov.HasItemConformingTo("public.url"))
                {
                    prov.LoadItem("public.url", null, (NSObject url, NSError error) =>
                    {
                        if (url == null)
                            return;

                        NSUrl newUrl = (NSUrl)url;
                        string urlStr = newUrl.ToString();
                        var appdef = new NSUserDefaults("group.com.xamarin.beambassador", NSUserDefaultsType.SuiteName);
                        appdef.SetString(urlStr, "appdef");
                        appdef.Synchronize();

                        CrossLocalNotifications.Current.Show("Xamarin", urlStr, 0, DateTime.Now.AddSeconds(2));
                    });
                }
            }
            catch (Exception e)
            {

            } 

Can anyone help me ?

Answers

Sign In or Register to comment.