I'm try to share text on Whatsapp in wp8 - c#

I'm try to share text on whtsapp where below method not show the whtsapp messanger.
ShareStatusTask shareStatusTask = new ShareStatusTask();
shareStatusTask.Status = jokeId;
shareStatusTask.Show();
But How can i share the text on whtsapp or other messanger

This is how I called whatsapp from my app but I haven't tried anything with sending some data to it. You will have to check it somewhere in their documentation.
private async void SendWhatsAppMessage()
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("whatsapp:"));
}

You can try the Share Link Task as follows-
ShareLinkTask shareLinkTask = new ShareLinkTask();
shareLinkTask.Title = "Code Samples";
shareLinkTask.LinkUri = new Uri("http://code.msdn.com/wpapps", UriKind.Absolute);
shareLinkTask.Message = "Here are some great code samples for Windows Phone.";
shareLinkTask.Show();
Share Link Task is a little different from Share Status Task.
In both cases your app is sending some data to share, but the other application (whatsapp in this case) must also accept the data your app is sending.
But Whatsapp currently does not support ShareLinkTask or ShareStatusTask.
You should implement these in your application code. when whatsapp starts supporting them, it will appear in the list and it will be possible to share data directly with whatsapp.

Related

Xamarin DisplayAlert not work on android live player

I use DisplayAlert in my project for displaying content of page, it works on UWP(universal Windows) local machine. But when i try to use this application on Xamarin live player on Android my button does not want work.
my code in button_Clicked:
WebClient myWebClient = new WebClient();
Page p = new Page();
byte[] myDataBuffer = myWebClient.DownloadData(URL);
var download = Encoding.ASCII.GetString(myDataBuffer);
p.DisplayAlert("page:", download, "close");
Difrent button without DisplayAlert works well in Live player.
The live player has many limitations. It's better to test your app on an emulator or test it on a real device through a USB-cable.
And I think you should just call this.DisplayAlert("page:", download, "close") instead of p.DisplayAlert("page:", download, "close");

Is it possible to launch system/third party app using an NDEFLaunchApp record to get the URI and by using LaunchUriAsync without NFC Tags?

So I have spent the whole night looking like a zombie in the morning trying to figure out how the OS handles an NFC tap for an NDEFLaunchApp Record and I have known the following.
I'm pretty sure that there is a workaround which lets you launch a system app / third party app (if you know the product Id / GUID) from your app. As there are apps in the Windows Phone Store which I have somehow figured out what I've been trying to.
I have come up with the following code:
NdefLaunchAppRecord appLaunchRecord = new NdefLaunchAppRecord();
appLaunchRecord.AddPlatformAppId("WindowsPhone", "{App GUID}");
appLaunchRecord.Arguments = "_default";
// Creating a new NdefMessage from the above record.
var message = new NdefMessage { appLaunchRecord };
// Getting the record from the message that we just created
foreach (NdefLaunchAppRecord record in message)
{
var specializedType = record.CheckSpecializedType(false);
if (specializedType == typeof(NdefLaunchAppRecord))
{
var x = String.Join(" ", record.Payload);
// Getting the payload by GetString gets a formatted Uri with args
string result = System.Text.Encoding.UTF8.GetString(record.Payload, 0, record.Payload.Length);
// result = "\0\fWindowsPhone&{5B04B775-356B-4AA0-AAF8-6491FFEA5630}\0\b_default";
// result = "(null)(form feed)WindowsPhone&{App GUID}(null)(backspace)_default
// So this will be sent to the OS and I believe the OS will then launch the specified app by an unknown protocol
// like xxx://result
// and the app will be launched?
// So is it then possible to somehow call the following:
await Windows.System.Launcher.LaunchUriAsync(new Uri("OUR MAGIC RESULT?", UriKind.RelativeOrAbsolute));
If anyone has / can figure out a way for this, it would be a REAL Service to the WP Community as developers are restricted by Microsoft to open certain settings / apps which are actually needed by those apps. For instance (speech settings, audio settings, about settings, alarms, region settings, date+time);
APPS that possibly have a workaround:
Music Hub Tile (Launches the old Music+Videos Hub)
http://www.windowsphone.com/en-gb/store/app/music-hub-tile/3faa2f9e-6b8d-440a-bb60-5dd76a5baec1
Tile for Bing Vision
http://www.windowsphone.com/en-gb/store/app/tile-for-bing-vision/05894022-e18c-40a4-a6cc-992383aa7ee8
There are reserved uri schemes for bing and zune.
See: http://msdn.microsoft.com/en-us/library/windows/apps/jj207065(v=vs.105).aspx
Those two apps propably use these and have found some undocumented use of the scheme.
If there is an uri scheme that launches any app by guid from within your app, it is hidden well.
Currently you can only launch apps that registered for an uri scheme or file association.

Show Viber, Whatsup in Windows Phone 8.1 share contract

Hi I am developing an app that shares a picture in via Share contract in Windows Phone 8.1. My code is
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.DataRequested);
and
private async void DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
DataRequest request = args.Request;
request.Data.Properties.Title = "Unscramble this";
request.Data.Properties.Description = "";
request.Data.SetText(string.Format("Scrambled word is {0} and clue is {1}. Help me to unscramble this \r\n(via Unscramble Plus for Windows Phone)",scrambledString.ToUpper(),selectedMeanings.ToUpper()));
DataRequestDeferral deferral = request.GetDeferral();
// Make sure we always call Complete on the deferral.
try
{
//StorageFile logoFile = await Package.Current.InstalledLocation.GetFileAsync("Assets\\Logo.png");
StorageFile imagefile = await KnownFolders.PicturesLibrary.GetFileAsync("pic.png");
List<IStorageItem> storageItems = new List<IStorageItem>();
storageItems.Add(imagefile);
request.Data.SetStorageItems(storageItems);
}
finally
{
deferral.Complete();
}
}
where this show the share contract as below (including only Facebook, Mail apps)
But if you see in Sendtiment app for Windows Phone (http://www.windowsphone.com/en-us/store/app/sendtiment-cards/9c389cc5-5c00-4f8e-8bd4-e6fbb5040c24) it shows many apps like Viber, Whatsapp, Twitter.
How to get these Viber, Whatsapp like apps in my app's share contract?
Edit: (Addition) When I remove
request.Data.SetText(string.Format("Scrambled word is {0} and clue is {1}. \r\n(via Unscramble Plus for Windows Phone)",scrambledString.ToUpper(),selectedMeanings.ToUpper())); line, this shows OneDrive.
http://channel9.msdn.com/Series/Building-Apps-for-Windows-Phone-8-1/10
this might help, also make sure what kind of data you are sharing, as the app will show only if the Content type matches,
for example whatsapp will show only if you are sharing Video,Images but NOT phone contact.
if you use a Universal-App, Whatsapp will not shown. WhatsApp is a WP8.1 Silverlight-App.
This is the Problem!

Call Navigation/Maps/Drive with an Address in WP8.1 Application

I was wondering if it's possible to call the default navigation application within my Windows Phone 8.1 application. I have an address and I would like for the user to press a button and be able to navigate to that address through the default navigation app. If this is possible, how do I do it?
Thanks for your time,
Johan
You can launch turn-by-turn directions apps using the ms-drive-to and ms-walk-to schemes (depending on the type of directions you want) but you first need to get a geocoordinate for the address that you have. Since you're targeting Windows Phone 8.1, you can use the MapLocationFinder class in the Windows.Services.Maps namespace.
string locationName = "Empire State Building";
string address = "350 5th Avenue, New York City, New York 10018";
var locFinderResult = await MapLocationFinder.FindLocationsAsync(
address, new Geopoint(new BasicGeoposition()));
// add error checking here
var geoPos = locFinderResult.Locations[0].Point.Position;
var driveToUri = new Uri(String.Format(
"ms-drive-to:?destination.latitude={0}&destination.longitude={1}&destination.name={2}",
geoPos.Latitude,
geoPos.Longitude,
locationName));
Launcher.LaunchUriAsync(driveToUri);
the official solution is:
Uri uri = new Uri("ms-drive-to:?destination.latitude=" + latitude.ToString(CultureInfo.InvariantCulture) +
"&destination.longitude=" + longitude.ToString(CultureInfo.InvariantCulture))
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
if (success)
{
// Uri launched.
}
else
{
MessageBox.Show("error");
}
But, there is a problem with this solution.
If you use the nokia programs (HERE), it works fine.
if you want to use waze, you have to add origin.latitude and origin.longitude.
in the MSDN page, They said that it is not necessary, but in fact, you have to write it.
I am already not enable to load moovit but if someone has an issue, it'll help me a lot.

Sharing from Windows Phone 8

I am working on a Windows Phone 8 app and am trying to share content through the DataTransferManager. The Windows API documentation says it is supported in Windows Phone but when the DataTransferManager.GetForCurrentView() function is called I get an exception
System.NotSupportedException was unhandled by user code
HResult=-2146233067
Message=Specified method is not supported.
Source=Windows
InnerException:
I have been searching for an answer and can't find anyone else with the same issue, any help would be appreciated. All samples on this topic seem to be Windows 8 specific, but Phone 8 does include these functions. Here's sample code from my app.
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(dataTransferManager_DataRequested);
}
private void dataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
DataPackage requestData = e.Request.Data;
requestData.Properties.Title = "Share Text Example";
requestData.Properties.Description = "An example of how to share text.";
requestData.SetText("Hello World!");
}
private void Button_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
{
DataTransferManager.ShowShareUI();
}
Again, the exception is shown when the page loads on the DataTransferManager.GetForCurrentView(); function so it doesn't get to the other lines, but included them anyway. I've tried adding/removing permissions and assemblies but must be missing something. I've also tried putting the function in different events (such as the onTap function) with the same results.
If anyone is interested in trying this on their own here is some documentation:
DataTransferManager
DataRequested
DataPackage
GetForCurrentView()
UPDATE
Although it may not be the best solution given the context of this question, I am implementing the Email/Sms/Link Tasks as described below rather than using the DataTransferManager. It seems that DataTransferManager may not be accessible in WP8 and although the tasks will take a number of different functions they seem to be the best way to perform the intended functionality.
I think I have found most of what I was looking for with Launchers... Rather than just using the Windows 8 general sharing functionality I can be specific with Tasks/Launchers.
Unfortunately it doesn't have as many sharing options as the charm does, I will be implementing several functions for email/sms/social but so far this is the best solution.
Here are the functions that I will be implementing
private void ShareLink(object sender, System.Windows.Input.GestureEventArgs e)
{
ShareLinkTask shareLinkTask = new ShareLinkTask()
{
Title = "Code Samples",
LinkUri = new Uri("http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff431744(v=vs.92).aspx", UriKind.Absolute),
Message = "Here are some great code samples for Windows Phone."
};
shareLinkTask.Show();
}
private void ShareEmail(object sender, System.Windows.Input.GestureEventArgs e)
{
EmailComposeTask emailComposeTask = new EmailComposeTask()
{
Subject = "message subject",
Body = "message body",
To = "recipient#example.com",
Cc = "cc#example.com",
Bcc = "bcc#example.com"
};
emailComposeTask.Show();
}
private void ShareSMS(object sender, System.Windows.Input.GestureEventArgs e)
{
SmsComposeTask smsComposeTask = new SmsComposeTask()
{
Body = "Try this new application. It's great!"
};
smsComposeTask.Show();
}
Ref:
Launchers for Windows Phone
Share Link Task
According to my API reference, DataTransferManager is reserved for native apps only. Windows Phone API Quickstart.
Have you tried using the fully qualified method? It would be something like this:
DataTransferManager dataTransferManager = indows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
Also, make sure your target is Windows Phone 8.
The Windows 8 Share Contract isn't supported on WP8. There isn't even a Share charm on WP8. Why are you trying to use the DataTransferManager?
Instead of using the Share Contract, most usecases can work just fine with WP8 app2app custom protocols and file extensions. Using WP8 app you can transfer files and data across apps. Althrough the standardized contract of the Share Contract is gone, apps can create their own contracts using custom protocols and file extensions.
Here for example you can learn more about a real-world 3rd party implementation of Nokia Music custom protocols.

Categories