viezel/TiSocial.Framework

Callback Constants

Opened this issue · 3 comments

Hey guys. Sorry for opening another issue, but I feel this one's important.

According to the README there are some constants for the callback, depending on the type of share you select.

Let's take Facebook as an example.

ACTIVITY_FACEBOOK: UIActivityTypePostToFacebook

But when evaluating this on runtime:

case dk.napp.social.ACTIVITY_FACEBOOK:
Ti.API.info("User shared on Facebook");
break;

...I never get into the selected case.

After debugging I discovered the Activity Name differs a little, not only from the constant but also between devices.

For iPhone: com.apple.UIKit.activity.PostToFacebook
For iPad: com.facebook.Facebook.ShareExtension

[INFO] : {
[INFO] : activity = 383813760;
[INFO] : activityName = "com.facebook.Facebook.ShareExtension";
[INFO] : bubbles = 1;
[INFO] : cancelBubble = 0;
[INFO] : platform = activityPopover;
[INFO] : source = "[object DkNappSocialModule]";
[INFO] : success = 1;
[INFO] : type = complete;
[INFO] : }

Probably UIActivityTypePostToFacebook is from older versions of the Facebook app and also iOS.

Same happens for Twitter, and even the Mail app.

I hope this is helpful as a report. Thanks!!

Hi @JuanP6, I don't use the module but I think you have to call the constant on the declared variable of the module. If you have var social = require("dk.napp.social"); than you call it on social. ACTIVITY_FACEBOOK.

Hi @hansemannn,
Certainly! I am already doing that.
The problem is that the module's constants are not matching the actual name of the activity.

The value of Facebook's constant is UIActivityTypePostToFacebook.
But for instance, in iOS 9, the actual name of said activity is com.apple.UIKit.activity.PostToFacebook.

So in the callback, I can't really use the constants for operations.
Actual code snippet from my project:

//case Alloy.Globals.Social.ACTIVITY_FACEBOOK:
case "com.apple.UIKit.activity.PostToFacebook":
(...)
break;

And this is only for iPhones. For tables, the activity is a modal, and the event returns "com.facebook.Facebook.ShareExtension".

This is certainly iOS and Facebook's fault, it renders the module's constants useless.

Same for twitter.
Phones: "com.apple.UIKit.activity.PostToTwitter"
Tablets: "com.atebits.Tweetie2.ShareExtension"

The reason is, that it calls different share extensions (see here). So I think you should use the iPad sharing dialog there. Does that help?