I am developing a WP8.1 app, when I try using ShareMediaTask to share a picture it shows me a list of apps where I will share the picture. Facebook, Twitter and other apps like Whatsapp are not included in the list; it shows me only share to OneNote. Taking note that I debug from device with Facebook and Twitter installed on it.
If someone could help me thankfully.
This is my simple code :
ShareMediaTask shareMediaTask = new ShareMediaTask();
shareMediaTask.FilePath = fileName;
shareMediaTask.Show();
Do I have to add something ?!
You'll want to take a look at Sharing content for Windows Runtime apps. Sharing is different between Silverlight and Runtime apps.
Here is a basic sample on how to share files:
When you are ready to share:
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager,
DataRequestedEventArgs>(this.ShareStorageItemsHandler);
And then populating the data:
private async void ShareStorageItemsHandler(DataTransferManager sender,
DataRequestedEventArgs e)
{
DataRequest request = e.Request;
request.Data.Properties.Title = "Share StorageItems Example";
request.Data.Properties.Description = "Demonstrates how to share files.";
// Because we are making async calls in the DataRequested event handler,
// we need to get the deferral first.
DataRequestDeferral deferral = request.GetDeferral();
// Make sure we always call Complete on the deferral.
try
{
StorageFile logoFile =
await Package.Current.InstalledLocation.GetFileAsync("Assets\\Logo.png");
List<IStorageItem> storageItems = new List<IStorageItem>();
storageItems.Add(logoFile);
request.Data.SetStorageItems(storageItems);
}
finally
{
deferral.Complete();
}
}
Only apps that implement sharing will show up in the list. Currently Twitter and Facebook have not released an app that implements sharing.
For more information of receiving shared content, see this doc.
Related
I am creating an app in Xamarin.Forms(C#) that is cross platform. I have a website that is also a pwa(progressive web app). I am trying to access it through a WebView and also allow for offline viewing of the last data cached. I have it working perfectly on Android by enabling:
webView.Settings.SetAppCacheEnabled(true);
However I cannot seem to get it to work correctly on iOS.
I am very new to app development and am trying to learn. Any help in learning would be appreciated.
Simple mock/poc example:
ToolbarItem refresh;
WebView webView;
public TestingWebCache() {
InitializeComponent();
Title = "Website";
IconImageSource = "airport.png";
webView = new WebView();
refresh = new ToolbarItem {
IconImageSource = "refresh.png"
};
refresh.Clicked += Refresh;
ToolbarItems.Add(refresh);
init();
Content = webView;
}
private void init() {
webView.Source = "https://www.google.com" //not the website im using but used for testing
}
private async void Refresh(object sender, EventArgs e) {
TRCWebViewItem.Reload();
}
I have looked at many resources, including the iOS WKWebView documentation. I have a feeling that I am just missing a vital piece of information that will stitch everything together.
I cannot download the html and display that way because the actual website it’s not just basic HTML and CSS
This issue was fixed by having the web developer also set the Application Cache in addition to the Cache Storage. As of iOS 10 WKWebview default is set to cache the webview but AppCache must be set in the website level. Android can handle if just the Cache Storage is set but iOS cannot.
I am creating a UWP application and I want to use the Onedrive API so that users can save a copy of their files in their Onedrive account, but I don't get it, so far I have only managed to login what I want is:
upload files
download files
and synchronize if any of them is modified
Create folders
Delete Files
This code achieves the login, but I can not move beyond this, as would proceed for upload files or download them
private async void btn_Login_Click(object sender, RoutedEventArgs e)
{
if (this.oneDriveClient == null)
{
try
{
// Setting up the client here, passing in our Client Id, Return Url,
// Scopes that we want permission to, and building a Web Broker to
// go do our authentication.
this.oneDriveClient = await OneDriveClient.GetAuthenticatedMicrosoftAccountClient(
clientId,
returnUrl,
scopes,
webAuthenticationUi: new WebAuthenticationBrokerWebAuthenticationUi());
// Show in text box that we are connected.
txtBox_Response.Text = "We are now connected";
// We are either just autheticated and connected or we already connected,
// either way we need the drive button now.
btn_GetDriveId.Visibility = Visibility.Visible;
}
catch (OneDriveException exception)
{
// Eating the authentication cancelled exceptions and resetting our client.
if (!exception.IsMatch(OneDriveErrorCode.AuthenticationCancelled.ToString()))
{
if (exception.IsMatch(OneDriveErrorCode.AuthenticationFailure.ToString()))
{
txtBox_Response.Text = "Authentication failed/cancelled, disposing of the client...";
((OneDriveClient)this.oneDriveClient).Dispose();
this.oneDriveClient = null;
}
else
{
// Or we failed due to someother reason, let get that exception printed out.
txtBox_Response.Text = exception.Error.ToString();
}
}
else
{
((OneDriveClient)this.oneDriveClient).Dispose();
this.oneDriveClient = null;
}
}
}
}
I created a sample repository in github:Onedrive Sync Files Sample
I have already tried using Dropbox, Gdrive, but its implementation for UWP seems to be much more complex, so I chose OneDrive. any answer will be very helpful thanks in advance
How to Sync files with OneDrive API in C#
For using OneDrive, we suggest you implement OneDrive feature with OneDrive Service that is part of Windows Community Toolkit .
Getting Started
To use the OneDrive API, you need to have an access token that authenticates your app to a particular set of permissions for a user. In this section, you'll learn how to:
Register your application to get a client ID and a client secret.
Sign your user in to OneDrive with the specified scopes using the token flow or code flow.
Sign the user out (optional).
And this is official code sample that you could refer.
I am using the method below in order to share uri's from my app.
ShareTextRequest share = new ShareTextRequest
{
Uri = uri,
Title = "Share Link"
};
await Share.RequestAsync(share);
All is working fine on both Android and iOS, however I am running into an issue as I would like to track and log to what applications the users are sharing the link, for security purposes as per company policy.
An example of the log would be something like;
{
'UserId': '999',
'Link': 'http://example.com',
'SharedTo': 'Facebook',
'SharedOn': '29/08/2019 11:00.000'
}
Would it be possible to use a callback method for example, where I can return the name of the application the link was shared to?
I have already tried accessing any returns of the function but it returns void.
My only other option might be to create a custom share functionality without using the native options.
I want to create an WP8 app that allow user to upload images to their dropbox account. Just one click of the button it will authorize if haven't already then upload the image, otherwise it just uploads it.
I followed the instructions here to create the following codes for the event-handler:
private async void toDropBoxBtn_Tap(object sender,System.Windows.Input.GestureEventArgs e)
{
DropBoxConfiguration config = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox) as DropBoxConfiguration;
DropBoxRequestToken requestToken = DropBoxStorageProviderTools.GetDropBoxRequestToken(config, "MY KEY", "MY SECRET"); // The code hangs at this line
String AuthorizationUrl = DropBoxStorageProviderTools.GetDropBoxAuthorizationUrl(config, requestToken);
ICloudStorageAccessToken accessToken = DropBoxStorageProviderTools.ExchangeDropBoxRequestTokenIntoAccessToken(config, "7nu03leznnz6x74", "ex3gge8av7kp9lq", requestToken);
}
The code just hangs at the 2nd line with no error or exception. I don't know what I've do wrong. Feel free to ask for more information. Thank you.
I am developing a Windows8 Metro App using c# xaml and I have to send the app link as an e-mail to someone using the share contract.
What I have tried is
private void RegisterForShare()
{
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.ShareLinkHandler);
}
private void ShareLinkHandler(DataTransferManager sender, DataRequestedEventArgs e) {
DataRequest request = e.Request;
request.Data.Properties.Title = "Sharing My Link";
request.Data.Properties.Description = "Add a link (URI) to share";
var _Uri = new Uri("https://login.live.com/");
Windows.System.Launcher.LaunchUriAsync(_Uri);
}
And also,
void App_QuerySubmitted(Windows.ApplicationModel.DataTransfer.DataTransferManager sender, Windows.ApplicationModel.DataTransfer.DataRequestedEventArgs args)
{
App.SettingsFlyout.Equals(args.Request, ApplicationExecutionState.Running);
}
But it works in a way where the specified link just opens and not a feature where the email of the link could be sent to soemone.
Any suggestions or solutions please?
While you can use the share charm to let the user sent text if you want to the user to definitely send email (as opposed to Twitter / Facebook) then you should use the mailto protocol.
await Launcher.LaunchUri(new Uri("mailto://test#address.com?subject=email"));
There's no built-in API for sending emails. Microsoft recommend to use share charm to send the email. Though if you want to send email via you need to go for commercial library called Mail.dll
Try this
var mailto = new Uri("mailto:?to=recipient#example.com&subject=Your subject&body=Your text");
await Windows.System.Launcher.LaunchUriAsync(mailto);