예제 #1
0
        public async Task SendOpenGraph(object source, ChallengeModel model, string message = null, byte[] data = null, Action <ChallengesFacebookShareResponseType> viewModelResponse = null, ShareTemplateModel shareTemplate = null, ShareResponseModel shareResponse = null)
        {
            ViewModelResponse = viewModelResponse;
            ShareDialog dialog = new ShareDialog(source as Activity);

            dialog.RegisterCallback((source as MainActivity).CallBackManager, this);
            if (shareTemplate == null || shareResponse == null)
            {
                await SL.Manager.RefreshShareTemplate(model.ShareTemplateURL, (response) =>
                {
                    ShareTemplate = response?.ShareTemplate;
                    shareResponse = response;
                });
            }
            else
            {
                ShareTemplate = shareTemplate;
            }

            OpenGraphWasTry = true;
            var openGraphBuilder = new ShareOpenGraphObject.Builder();

            openGraphBuilder.PutString("og:type", "object");
            openGraphBuilder.PutString("og:title", string.IsNullOrEmpty(ShareTemplate?.PostTitle) ? ShareTemplate?.PostHref : ShareTemplate.PostTitle);
            openGraphBuilder.PutString("og:description", string.IsNullOrEmpty(message) ? ShareTemplate?.PostDescription ?? " " : message);
            //openGraphBuilder.PutString("og:url", ShareTemplate?.PostHref ?? model.ShareImage);
            if (model != null && (model.FBShareType == "image" || !string.IsNullOrEmpty(model.ShareImage)))
            {
                openGraphBuilder.PutString("og:image", model.ShareImage);
            }
            if (model != null && (model.FBShareType == "link" || model.FBShareType == null))
            {
                openGraphBuilder.PutString("og:url", ShareTemplate?.PostHref ?? model.ShareImage);
            }
            ShareOpenGraphObject openGraph = openGraphBuilder.Build();
            ShareOpenGraphAction action    = new ShareOpenGraphAction.Builder()
                                             .SetActionType("news.publishes")
                                             .PutObject("object", openGraph)
                                             .JavaCast <ShareOpenGraphAction.Builder>()
                                             .Build();
            ShareOpenGraphContent contentOpenGraph = new ShareOpenGraphContent.Builder()
                                                     .SetPreviewPropertyName("object")
                                                     .SetAction(action)
                                                     .Build();

            dialog.Show(contentOpenGraph, ShareDialog.Mode.Web);
            //ShareDialog.Show(source as Activity, contentOpenGraph);
        }
예제 #2
0
        public void ShowPostToFacebook()
        {
            ShareDialog sharedialog = new ShareDialog (this);
            sharedialog.RegisterCallback (this.facebookcallbackmanager,new FaceBookShareResult(this));
            if (ShareDialog.CanShow(Java.Lang.Class.FromType(typeof(ShareOpenGraphContent)))) {
             				var builder = new ShareLinkContent.Builder ();
                var opengraphcontent = new ShareOpenGraphContent.Builder ();
                if (this.eventcard.eventinfo.representative_needed.Equals ("N")) {
                    builder.SetContentUrl (global::Android.Net.Uri.Parse (this.eventcard.eventinfo.sell_ticket_url));
                    string message = String.Format (RaffleDetailDate.c_facebookMessageTemplate_WithLink, this.eventcard.eventinfo.organization, this.eventcard.eventinfo.location_name);
                    builder.SetContentDescription (message);

                } else {
                    builder.SetContentUrl (global::Android.Net.Uri.Parse (RaffleDetailDate.Tap5050WebPageLink));
                    string message = string.Format(RaffleDetailDate.c_facebookMessageTemplate_NoLink, this.eventcard.eventinfo.organization);
                    builder.SetContentDescription (message);
                }
                if(!string.IsNullOrEmpty(this.eventcard.eventinfo.event_name)){
                    builder.SetContentTitle(this.eventcard.eventinfo.event_name);
                }
                string url = "https://tap5050.com/apex/wwv_flow_file_mgr.get_file?p_security_group_id=9113403474056812&p_fname=tap5050logo.png";
                if(!string.IsNullOrEmpty(this.eventcard.eventinfo.image_url)){
                    url = this.eventcard.eventinfo.image_url;
                }
                //builder.SetImageUrl (global::Android.Net.Uri.FromFile(TapUtil.bitmapToFile(this.eventcard.imagemap)));
                builder.SetImageUrl(global::Android.Net.Uri.Parse(url));
                ShareLinkContent content = builder.Build ();
                sharedialog.Show (content);
            }
        }