private void ShareOnService(SLServiceKind service, string title, string status, string link)
		{
			SLComposeViewController slComposer;
			if (SLComposeViewController.IsAvailable(service)) {
				slComposer = SLComposeViewController.FromService(service);
				slComposer.SetInitialText(status);
				if (title != null)
					slComposer.SetInitialText(String.Format("{0} {1}",title,status));
				else
					slComposer.SetInitialText(status);
				if (link != null)
					slComposer.AddUrl (new NSUrl (link));
				slComposer.CompletionHandler += (result) => {
					UIApplication.SharedApplication.KeyWindow.RootViewController.InvokeOnMainThread (() => {
						UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController (true, null);
					});
				};
				UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController (slComposer, true, null);
			}
		}
Ejemplo n.º 2
0
            public SocialRequest(SLServiceKind kind, string method, Uri url, IDictionary <string, string> parametrs, Account account)
                : base(method, url, parametrs, account)
            {
                var m = SLRequestMethod.Get;

                switch (method.ToLowerInvariant())
                {
                case "get":
                    m = SLRequestMethod.Get;
                    break;

                case "post":
                    m = SLRequestMethod.Post;
                    break;

                case "delete":
                    m = SLRequestMethod.Delete;
                    break;

                default:
                    throw new NotSupportedException("Social framework does not support the HTTP method '" + method + "'");
                }

                request = SLRequest.Create(kind, m, new NSUrl(url.AbsoluteUri), new NSMutableDictionary());
                UpdateParameters(request);

                Account = account;
            }
        private void ShareOnService(SLServiceKind service, string title, string status, string link)
        {
            SLComposeViewController slComposer;

            if (SLComposeViewController.IsAvailable(service))
            {
                slComposer = SLComposeViewController.FromService(service);
                slComposer.SetInitialText(status);
                if (title != null)
                {
                    slComposer.SetInitialText(String.Format("{0} {1}", title, status));
                }
                else
                {
                    slComposer.SetInitialText(status);
                }
                if (link != null)
                {
                    slComposer.AddUrl(new NSUrl(link));
                }
                slComposer.CompletionHandler += (result) => {
                    UIApplication.SharedApplication.KeyWindow.RootViewController.InvokeOnMainThread(() => {
                        UIApplication.SharedApplication.KeyWindow.RootViewController.DismissViewController(true, null);
                    });
                };
                UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(slComposer, true, null);
            }
        }
        private void ShowActionSheet(string status, string title = "", string link = "")
        {
            var actionSheet = new UIActionSheet("Share on");

            foreach (SLServiceKind service in Enum.GetValues(typeof(SLServiceKind)))
            {
                actionSheet.AddButton(service.ToString());
            }
            actionSheet.Clicked += delegate(object a, UIButtonEventArgs b) {
                SLServiceKind serviceKind = (SLServiceKind)Enum.Parse(typeof(SLServiceKind), actionSheet.ButtonTitle(b.ButtonIndex));
                ShareOnService(serviceKind, title, status, link);
            };
            actionSheet.ShowInView(UIApplication.SharedApplication.KeyWindow.RootViewController.View);
        }
Ejemplo n.º 5
0
        public void SendSocial(SLServiceKind framework)
        {
            var slComposer = SLComposeViewController.FromService(framework);

            if (slComposer == null)
            {
                new UIAlertView("Unavailable", "This social network is not available.", null, "OK").Show();
                return;
            }

            slComposer.CompletionHandler += (result) => {
                InvokeOnMainThread(() => DismissViewController(true, null));
            };
            PresentViewControllerAsync(slComposer, true);

            CreateAllNotifcations();
        }
Ejemplo n.º 6
0
 internal static NSString KindToType(SLServiceKind kind)
 {
     switch (kind){
     case SLServiceKind.Facebook:
         return SLServiceType.Facebook;
     case SLServiceKind.Twitter:
         return SLServiceType.Twitter;
     case SLServiceKind.SinaWeibo:
         return SLServiceType.SinaWeibo;
     case SLServiceKind.TencentWeibo:
         return SLServiceType.TencentWeibo;
     #if MONOMAC
     case SLServiceKind.LinkedIn:
         return SLServiceType.LinkedIn;
     #endif
     }
     return null;
 }
Ejemplo n.º 7
0
        private void ShareOnService(SLServiceKind service, string title, string status, string link, Action onShareDone)
        {
            if (SLComposeViewController.IsAvailable(service))
            {
                var slComposer = SLComposeViewController.FromService(service);
                slComposer.Title = title;
                slComposer.SetInitialText(status);
                slComposer.AddUrl(new NSUrl(link));

                slComposer.CompletionHandler += (result) => {
                    if (result == SLComposeViewControllerResult.Done && onShareDone != null)
                    {
                        onShareDone.Invoke();
                    }
                };

                ViewController.PresentViewController(slComposer, true, null);
            }
        }
Ejemplo n.º 8
0
        private void CreateNotification(SLServiceKind framework)
        {
            //check if they want notifications or not
            if (!Settings.Notifications)
            {
                return;
            }

            // create the notification
            var notification = new UILocalNotification();

            // configure the alert stuff
            notification.AlertAction = "Post It";
            switch (framework)
            {
            case SLServiceKind.Facebook:
                notification.AlertBody = "Facebook Post";
                break;

            case SLServiceKind.Twitter:
                notification.AlertBody = "Tweet";
                break;

            case SLServiceKind.SinaWeibo:
                notification.AlertBody = "Sina Weibo Post";
                break;

            case SLServiceKind.TencentWeibo:
                notification.AlertBody = "Tencent Weibo Post";
                break;
            }


            notification.FireDate = NSDate.Now.AddSeconds(.1);

            // schedule it
            UIApplication.SharedApplication.ScheduleLocalNotification(notification);
        }
Ejemplo n.º 9
0
        internal static NSString KindToType(SLServiceKind kind)
        {
            switch (kind)
            {
            case SLServiceKind.Facebook:
                return(SLServiceType.Facebook);

            case SLServiceKind.Twitter:
                return(SLServiceType.Twitter);

            case SLServiceKind.SinaWeibo:
                return(SLServiceType.SinaWeibo);

            case SLServiceKind.TencentWeibo:
                return(SLServiceType.TencentWeibo);

#if MONOMAC
            case SLServiceKind.LinkedIn:
                return(SLServiceType.LinkedIn);
#endif
            }
            return(null);
        }
Ejemplo n.º 10
0
			public SocialRequest (SLServiceKind kind, string method, Uri url, IDictionary<string, string> parametrs, Account account)
				: base (method, url, parametrs, account)
			{
				var m = SLRequestMethod.Get;
				switch (method.ToLowerInvariant()) {
					case "get":
					m = SLRequestMethod.Get;
					break;
					case "post":
					m = SLRequestMethod.Post;
					break;
					case "delete":
					m = SLRequestMethod.Delete;
					break;
					default:
					throw new NotSupportedException ("Social framework does not support the HTTP method '" + method + "'");
				}

				request = SLRequest.Create (kind, m, new NSUrl (url.AbsoluteUri), new NSMutableDictionary ());
				UpdateParameters (request);

				Account = account;
			}
Ejemplo n.º 11
0
 public SocialService(string serviceId, string title, SLServiceKind kind, NSString accountTypeIdentifier)
     : base(serviceId, title)
 {
     this.kind = kind;
     this.accountTypeIdentifier = accountTypeIdentifier;
 }
Ejemplo n.º 12
0
 public static bool IsAvailable(SLServiceKind serviceKind)
 {
     return(IsAvailable(SLRequest.KindToType(serviceKind)));
 }
Ejemplo n.º 13
0
 public static SLComposeViewController FromService(SLServiceKind serviceKind)
 {
     return(FromService(SLRequest.KindToType(serviceKind)));
 }
Ejemplo n.º 14
0
 public static SLRequest Create(SLServiceKind serviceKind, SLRequestMethod method, NSUrl url, NSDictionary parameters)
 {
     return Create (KindToType (serviceKind), method, url, parameters);
 }
Ejemplo n.º 15
0
		public SocialService (string serviceId, string title, SLServiceKind kind, NSString accountTypeIdentifier)
			: base (serviceId, title)
		{
			this.kind = kind;
			this.accountTypeIdentifier = accountTypeIdentifier;
		}
Ejemplo n.º 16
0
 public static bool IsAvailable(SLServiceKind serviceKind)
 {
     return IsAvailable (SLRequest.KindToType (serviceKind));
 }
Ejemplo n.º 17
0
 public static SLComposeViewController FromService(SLServiceKind serviceKind)
 {
     return FromService (SLRequest.KindToType (serviceKind));
 }
Ejemplo n.º 18
0
 public static SLRequest Create(SLServiceKind serviceKind, SLRequestMethod method, NSUrl url, NSDictionary parameters)
 {
     return(Create(KindToType(serviceKind), method, url, parameters));
 }
 /// <summary>
 /// Offers the option to post the image to facebook or twitter
 /// </summary>
 /// <param name='pictureId'>
 /// ID of the picture we wish to post
 /// </param>
 /// <param name='socialNetwork'>
 /// Type of social network we wish to post to
 /// </param>
 private void PostImageToSocialNetwork(Guid pictureId, SLServiceKind socialNetwork)
 {
     var filenameResolver = this.CreateFilenameResolver(pictureId);
     var socialNetworkMessenger = new SocialNetworkMessenger(this, socialNetwork);
     socialNetworkMessenger.PostImage(filenameResolver.MasterImageFilename);
 }