Skip to content

Share post, app freeze and close #89

Open
@DeanZhuo

Description

@DeanZhuo

If you are creating an issue for a BUG please fill out this information. If you are asking a question or requesting a feature you can delete the sections below.

Failure to fill out this information will result in this issue being closed. If you post a full stack trace in a bug it will be closed, please post it to http://gist.github.com and then post the link here.

Bug Information

App stopped when I try to post. nothing came out using a try-catch. do I need to install Facebook on my device?
I tried using my phone, with Facebook app installed. The post succeeds, but my app still crash. the same console log shows up.

Edited: I make a different app on my phone with the Facebook app installed. I managed to share the post, but then the app didn't show anything it should (dialog message, console log, and then PopAsync). I used the OnSharing event, but nothing happened.

Version Number of Plugin: 2.2.1
Device Tested On: Android Nokia 6
Simulator Tested On: Android Pixel 2
Version of VS: 16.8.1
Version of Xamarin: 16.8.000.255
Versions of other things you are using: Xamarin.Forms 4.8.0.1687, Xam.Plugin.Media 5.0.1

Steps to reproduce the Behavior

Login, move to post page, insert text and photo by camera, click the post button

Expected Behavior

showing post page by Facebook, post the pic with text, and return message

Actual Behavior

app freeze after button click

Code snippet

        string message = string.Empty;
        try
        {
            FacebookSharePhoto photo = new FacebookSharePhoto(text, imageArray);
            FacebookSharePhoto[] photos = new FacebookSharePhoto[] { photo };
            FacebookSharePhotoContent photoContent = new FacebookSharePhotoContent(photos, null, text);
            Console.WriteLine("Uploading...");
            var ret = await _facebookService.ShareAsync(photoContent);
            switch (ret.Status)
            {
                case FacebookActionStatus.Completed:
                    message = "Facebook post success";
                    Debug.WriteLine("Facebook post success");
                    break;

                case FacebookActionStatus.Canceled:
                    message = "Facebook post canceled";
                    Debug.WriteLine("Facebook post success");
                    break;

                case FacebookActionStatus.Unauthorized:
                    message = ret.Message;
                    Debug.WriteLine("Facebook post success");
                    break;

                case FacebookActionStatus.Error:
                    message = ret.Message;
                    Debug.WriteLine("Facebook post success");
                    break;
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("PostFB: " + ex.ToString());
        }
        return message;

my login code:

            string[] fbPermisions = { "publish_pages" };
            FacebookResponse<bool> response = await CrossFacebookClient.Current.LoginAsync(fbPermisions, 
            FacebookPermissionType.Publish);

on my other app:

            FacebookSharePhoto photo = new FacebookSharePhoto(text, data);
            FacebookSharePhoto[] photos = new FacebookSharePhoto[] { photo };
            FacebookSharePhotoContent photoContent = new 
           FacebookSharePhotoContent(photos, null, text);
            Console.WriteLine("Uploading...");
            var result = await _facebookService.ShareAsync(photoContent);
            switch (result.Status)
            {
                case FacebookActionStatus.Completed:
                    postmessage = "Completed";
                    Console.WriteLine("FacebookPost: " + postmessage);
                    break;

                case FacebookActionStatus.Canceled:
                    postmessage = "Canceled";
                    Console.WriteLine("FacebookPost: " + postmessage);
                    break;

                case FacebookActionStatus.Unauthorized:
                    postmessage = result.Message;
                    Console.WriteLine("FacebookPost: " + postmessage);
                    break;

                case FacebookActionStatus.Error:
                    postmessage = result.Message;
                    Console.WriteLine("FacebookPost: " + postmessage);
                    break;
            }

            _facebookService.OnSharing += (s, a) =>
            {
                switch (a.Status)
                {
                    case FacebookActionStatus.Completed:
                        //Shared post succesfully
                        break;
                }
            };

console logs:
https://gist.github.com/DeanZhuo/54e982124597bea5b14ab6f096d076b7

Screenshotst

image
after button click

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions