سؤال

I have created a Windows 8.1 application in WinJS and I have some HTML content that I am sharing.

I have implemented sharing as per the MS sample app (http://code.msdn.microsoft.com/windowsapps/Sharing-Content-Source-App-d9bffd84)

The sharing works well, except if I share to the official Twitter app.

The problem is that it inserts the entire article (500 characters or more) into the text area of the Twitter flyout.

Is there anyway to limit the characters when the user chooses to share to Twitter?

The problem can be replicated by installing the MS share example app, selecting "Share HTML content" and selecting the Twitter app from the share flyout (The Twitter app needs to be installed on your PC of coarse).

هل كانت مفيدة؟

المحلول 2

No, by design with contracts the source app doesn't know anything about the selected target, so there's not a mechanism to selectively change the source data depending on the target. In the case of the Twitter app, it shows all that text, yes, but won't allow you to tweet until you cut it down to the right size. The challenge in the Twitter app, of course, is that it gives you a really small area in which to view that text, and clearly there could be a better design in its Share target pane. That'd be good feedback to give Twitter in ratings & reviews.

I'm guessing by how you phrased the question that your source app is sharing a whole article (and ideally also setting the contentSourceApplicationLink property in the data package), and that you don't necessarily have a way for the user to select just a portion of that article. If that's the case, you could consider enabling the user to choose what kind of data to share and automatically invoke the Share charm in response to those commands. For example, they might choose to share just a link (using the data package's setWebLink method), or to share a summary, or a summary + shortened URI...basically to adapt your content for different possible targets in a generic way. After all, people might prefer this kind of behavior even for Facebook, email, and other targets, so providing some ability to control what's shared, either by selection or other types of commands, might be the best approach.

نصائح أخرى

The problem is that you don't know where your users will share to... you can tell the share charm what you want to share and you could shorten the text to 140 characters.

Using the Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView().ondatarequested event you can set to the argument the data you want to share, but as I said, if you want to trim the message you are sharing, you're doing it for every 'shareable' app. If the user then picks Twitter or OneNote is something you wouldn't know.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top