Unity Fabric AppCard not rendering

unity

#1

Hi all,

I’ve been trying to get the Fabric Unity plugin integrated into my Unity game. I followed the documentation here https://docs.fabric.io/unity/twitter/compose-tweets.html and call a method to post the App Card from a button in my game.

However when the tweet window comes up my App Card does not show the image I have defined in the code. The image URI is pointing to a location on my device and I am pretty sure it is correct. When I click tweet the tweet also does not appear on my timeline.

ADB Logcat doesn’t post anything useful that I can see and doesn’t show any errors for not finding the image I have specified. I am also following all requirements specified in the App Card requirements, my image is set to 800x320 px and the app I am referencing is live in the store. I have also acquired permissions to post App Cards but I’m not sure if that would be related to my current problem.

What could be the problem here? Any help is appreciated.


#2

Thanks for reaching out on this @RichardGillen, it’s a bit odd that there is nothing in Logcat especially on a failure to post the tweet. With the image now showing up correctly in the card, I’m wondering if the image is changing locations between when it’s saved and when your app tries to post it to Twitter. Can you try logging the location of the image and confirm it’s actually there on the device where your app believes it to be?


#3

Hi bonnell,

Thanks for your quick reply. I am using a variable to store the path to my image when it is being created by the Unity application. This same variable is then used to reference the location when creating the App Card so I am sure the path variable is correct.

I can also browse my device using a file manager and can confirm that the file is indeed where the path points to. Would the tweet not be going out if I got permissions for the wrong app? There is the twitter apps page and the fabric apps which fabric created for me so perhaps I made a mistake there.


#4

Thanks @RichardGillen and it sounds like the path is correct. Yes, the tweet would be rejected if for example, the app was using a Twitter Consumer Key that didn’t have the correct permissions. Since there are both the apps.twitter.com and fabric.io pages, it’s possible that there is a key conflict. Can you email into support(at)fabric(dot)io, reference this thread and include the Twitter Consumer Key you’re using so I can check it’s privileges?

-Mike


#5

Hi again,

Is this the key from the fabric.io dashboard or from the https://apps.twitter.com/ page?

I’m a bit confused about the difference between the two. Would it matter if the email I use to login to fabric is different from the twitter apps page?


#6

It’d be whichever key you’re using within the app itself.

If you’re going to be using Twitter through Fabric, then using the Fabric based keys is the best approach. However, if you submitted your other key for the permission, then you can email me the Fabric Twitter Consumer Key and I can whitelist it for you.

In essence, if you’re using Fabric, you should use the Fabric keys unless you had an existing app created through apps.twitter.com.


#7

Thanks Mike, that clears some things up.

Just letting you know that I sent the email with the consumer key included and referenced this thread.


#8

Perfect, thanks @RichardGillen!


#9

Hi Mike,

I tried following the instructions you emailed back to me but enabling debug mode seemed a bit more difficult than I’d thought. The link you sent only describes how to enable debugging in Android and I am on Unity, is there a way to do this through c# in Unity itself?

I built my game to an android studio project but have been unable to place the debugging code anywhere inside the project.

Additionally, how can I check what consumer key I am using within Unity? Just so I can make sure I am using the key I think I am.

Thanks


#10

Just an update. I’ve found where the key and secret are defined (On the FabricSettings.asset) and my keys and secret were set to the values for the app in app.twitter.com rather than the fabric generated apps. Is this correct?

I changed them to the fabric key and secret to investigate but it made no difference.

EDIT:

Well turns out you were right! I had been using a filtered version of logcat for some testing and forgot about it, so I was missing all the important log messages.

09-15 15:47:24.631 9493 14352 E TweetUploadService: Post Tweet failed
09-15 15:47:24.631 9493 14352 E TweetUploadService: com.twitter.sdk.android.core.TwitterException: Uri file path resolved to null
09-15 15:47:24.631 9493 14352 E TweetUploadService: at com.twitter.sdk.android.tweetcomposer.TweetUploadService.uploadAppCardTweet(TweetUploadService.java:107)
09-15 15:47:24.631 9493 14352 E TweetUploadService: at com.twitter.sdk.android.tweetcomposer.TweetUploadService.onHandleIntent(TweetUploadService.java:79)
09-15 15:47:24.631 9493 14352 E TweetUploadService: at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
09-15 15:47:24.631 9493 14352 E TweetUploadService: at android.os.Handler.dispatchMessage(Handler.java:102)
09-15 15:47:24.631 9493 14352 E TweetUploadService: at android.os.Looper.loop(Looper.java:148)
09-15 15:47:24.631 9493 14352 E TweetUploadService: at android.os.HandlerThread.run(HandlerThread.java:61)

So the path I am passing in seems to be failing, I’m sure it will work once I fix that.

This is the path I am using “/storage/emulated/0/Android/data/uk.co.company.myapp/files/AppCardImage.png”, is there something wrong with this as a URI?


#11

Thanks for the update @RichardGillen and glad we sorted through this at least most of the way. Since the URI path is responding to as null, what I’d do is log the URI path before trying to tweet the card and start with a basic URI path, then append more on and on until either the URI works or the invalid portion of it is shown.


#12

Ok I’ve made progress! I was defining the path entirely wrong. I didn’t realise that a URI has a specific format (file://my/path/name.png) so that was the problem in that case. The App Card now renders in the tweet prompt now which is good.

I was then getting a 403 error, but I deleted FabricSettings.asset and setup twitter kit again. This now gives me no errors when I tweet now, however only the text goes through and the App Card does not showup on my post history.

I read a similar thread on the forum and saw that it may be something to do with the permissions associated with my consumer key?


#13

Alright, even more progress! I checked the key once more and it still appears to me have the correct permissions. Can you check for any other reference to a Twitter Consumer Key in your project and see if there is another one causing a conflict?


#14

I think I’ll go through the process I set up the apps on apps.twitter.com and fabric and that might clear everything up.

So first I set up an app at apps.twitter.com, I setup fabric in Unity. I then clicked “use an existing account” and entered the key and secret from my app from apps.twitter.com. This created an app for me in Fabric and then I requested permissions to post App Cards using the key and secret from the app in Fabric not from apps.twitter.com.

So perhaps I have requested permissions for the incorrect app?

Currently I get the 403 with secret and key from apps.twitter.com and get the issue of the App Card not appearing when I use the key and secret from the Fabric app. I hope this clears things up a bit and might reveal the issue. I can’t see any conflicting keys on my side and the way I have set up things seems incorrect.

Thanks


#15

Thanks @RichardGillen and it is possible you got the permissions for the wrong app. Let’s use the Fabric created Twitter Consumer Key if that works for. Send that value over and I’ll get you the cards permission.


#16

Hi Mike,

I’ve sent the email along but with both my keys this time (The fabric.io key was already whitelisted but I sent it anyway). If both are whitelisted them I can play around with the settings and hopefully get it going.

Cheers!


#17

Hi again,

I must admit, I’ve been slightly foolish. When I was checking if the App Cards were being posted I only ever saw the text I was posting. But I was using the browser to check my twitter feed for the posts I was making.

Then I thought, why would a call to action to install an Android app appear on a browser window on a desktop? So I installed the twitter app on my phone and saw the App Card and my tweet appearing perfectly.

It looks like everything was working since I fixed the URI I was using. Can’t believe it never occurred to me before, sorry for the confusion!

Thanks for all your help Mike, it’s been very much appreciated!


Android app card sharing not working
Fabric for Unity - ClassNotFoundException TwitterAuthToken in new project
#18

I’m should thought of this as well - glad it’s all set now and have a great weekend!