Unable to share data by mail with windows 8.1 charm bar - c#

I'm currently testing some code exemple provided by microsoft on msdn to check how sharing content from application with the mail application in the charm bar.
The code that microsoft gives you looks like this :
private void RegisterForShare()
{
DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.ShareTextHandler);
}
private void ShareTextHandler(DataTransferManager sender, DataRequestedEventArgs e)
{
DataRequest request = e.Request;
request.Data.Properties.Title = "Share Text Example";
request.Data.Properties.Description = "A demonstration that shows how to share text.";
request.Data.SetText("Hello World!");
}
I call the function that register the view for sharing in the following method like it's asked in the tutorial :
public override void OnNavigatedTo(object navigationParameter, Windows.UI.Xaml.Navigation.NavigationMode navigationMode, Dictionary<string, object> viewModelState)
{
SelectedContact = (Contact)navigationParameter;
base.OnNavigatedTo(navigationParameter, navigationMode, viewModelState);
RegisterForShare();
}
But when I'm opening Sharing in the charm bar and clicking on mail, a message telling me that something went wrong with the information that i'd like to share.
I've check all over the internet but I can't find any similar error.
So if someone got a hint about what went wrong ?
I'm using Visual Studio Professional 2013 with the Emulator to test my app.

That might be because you didn't set your account email in the Mail application.

Related

iOS phone link opening message app instead of calling the number

I want a phone number from a TextView to call the phone number when clicked:
The issue I am facing is that when clicking the link, the message app is opening instead. I tried the following code in iOS 12 and it worked as expected, but when I try on iOS 13 and 14, the message app opens instead of making a call using the "phone dialer app".
Tentative 1:
textView.Editable = false;
textView.DataDetectorTypes = UIDataDetectorType.PhoneNumber;
Tentative 2:
var phoneNumberLink = new Dictionary<string, string>(){ { "(855) 757-7328","tel:8557577328" } }
textView.Editable = false;
textView.SetAttributedTextForLinks("Please call us at (855) 757-7328", phoneNumberLink);
Actually, telpromt://0123456789 also did not work. I had to intercept the interaction with URL, the recommended ShouldInteractWithUrl did not work (ShouldInteractWithUrl was not triggered or called), so I had to use AllowUrlInteraction instead. The code looked something like this:
var description = new KiteEmbeddedLinkTextView()
{
Editable = false,
DataDetectorTypes = UIDataDetectorType.PhoneNumber,
Text = message.MessageText
};
description.AllowUrlInteraction += AllowUrlInteraction;
private bool AllowUrlInteraction(UITextView textView, NSUrl url, NSRange characterRange, UITextItemInteraction interaction)
{
UIApplication.SharedApplication.OpenUrl(url);
return false;
}
For some reason none of the previous options worked for me, besides this one.
See:
https://forums.xamarin.com/discussion/60345/uitextview-and-clickable-phonenumbers
How to intercept click on link in UITextView?
As mentioned https://forums.xamarin.com/discussion/33798/open-phone-dialer-from-app
The correct way to open the dialer is
telprompt://0123456789
Make sure that there are no spaces.

Open ID with Google and dotnetopenauth - Passing query string

I have some code that uses Google Apps as an Open ID provider to authenticate to my web application that is based on the example https://developers.google.com/google-apps/marketplace/tutorial_dotnet.
It all works as expected. However, when redirected to the Google Login screen, the 'Stay Signed In' checkbox is selected by default. I have found that if I manually add &rm=false to then end of the URL, the checkbox is unselected, which I believe is a more secure default option.
My question is, how can I pass &rm=false in my code. I've looked at AddCallbackArguments but this doesn't seem to be the way to do it.
Code is
private static readonly HostMetaDiscoveryService GoogleAppsDiscovery = new HostMetaDiscoveryService
{
UseGoogleHostedHostMeta = true,
};
private static readonly OpenIdRelyingParty relyingParty;
static login()
{
relyingParty = new OpenIdRelyingParty();
relyingParty.DiscoveryServices.Clear();
relyingParty.DiscoveryServices.Insert(0, GoogleAppsDiscovery);
}
protected void buLogin_Click(object sender, EventArgs e)
{
IAuthenticationRequest request = relyingParty.CreateRequest("mydomain");
request.RedirectToProvider();
}

Problems using captured access token to retrieve user's facebook information

I have been attempting to code a windows form application that interacts with facebook to retrieve the access token that has permissions to get some of the user's information. I have been trying to get the birthday of myself using the following code but it keeps giving me the 400 bad request error. Basically after running this code, and logging in at the authentication it is suppose to show a messagebox containing the user's birthday. In this case, I am using my own user id in the api.GET method. It seems to be the access token issue as when I don't pass in any tokens, i can view public available information such as id using the same code but I print out the access token to check and it seems to be alright. Any help would be much appreciated. First time posting here
public partial class AccessTokenRetrieval : Form
{
private string accessToken=null;
public AccessTokenRetrieval()
{
InitializeComponent();
}
private void accessTokenButton_Click(object sender, EventArgs e)
{
string getAccessTokenURL = #"https://graph.facebook.com/oauth/authorize?client_id=223055627757352&redirect_uri=http://www.facebook.com/connect/login_success.html&type=user_agent&display=popup&grant_type=client_credentials&scope=user_photos,offline_access";
getAccessTokenWebBrowser.Navigate(getAccessTokenURL);
}
private void getAccessTokenWebBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
string successUrl = #"http://www.facebook.com/connect/login_success.html";
string urlContainingUserAuthKey = e.Url.ToString();
MessageBox.Show(urlContainingUserAuthKey);
int searchInt = urlContainingUserAuthKey.IndexOf(successUrl);
MessageBox.Show(searchInt.ToString());
if (urlContainingUserAuthKey.IndexOf(successUrl) == -1)
{
string accessTokenString;
accessTokenString = Regex.Match(urlContainingUserAuthKey, "access_token=.*&").ToString();
this.accessToken = accessTokenString.Substring(13, accessTokenString.Length - 14);
//100001067570373
//MessageBox.Show(accessToken);
accessTokenTextBox.Text = this.accessToken;
Facebook.FacebookAPI api = new Facebook.FacebookAPI(this.accessToken);
JSONObject me = api.Get("/100001067570373");
MessageBox.Show(me.Dictionary["user_birthday"].String);
}
}
#
I would request you to try http://facebooksdk.codeplex.com and checkout the samples folder.
It includes sample for WinForms authentication and also making various request to Facebook.
Here are other useful links that I would recommend you to read.
http://blog.prabir.me/post/Facebook-CSharp-SDK-Writing-your-first-Facebook-Application.aspx
http://blog.prabir.me/post/Facebook-CSharp-SDK-Making-Requests.aspx

Creating Facebook Application in asp.net

I want to create a Facebook IFRAME applicaton with asp.net. I just want to know should I need to host the application some where over internet? If yes, how could I test my application on localhost?
Update:
I just want a simple app for displaying a user name with "Hello." Can anyone show me the code for that with the complete web.config configuration?
I'm trying this code
using facebook.web;
namespace TestFbApplication
{
public partial class _Default:facebook.web.CanvasFBMLBasePage
{
facebook.Components.FacebookService _fbService = new facebook.Components.FacebookService();
private const string FACEBOOK_APPKEY = "66a8278bb94d969247a80815bab686e5"; // From the Facebook application page
private const string FACEBOOK_SECRET = "de76280e4ddaef72ac2166afe7ffb9d5"; // From the Facebook application page
protected void Page_PreInit(object sender, EventArgs e)
{
base.RequireLogin = false;
_fbService.IsDesktopApplication = false;
_fbService.ApplicationKey = FACEBOOK_APPKEY;
_fbService.Secret = FACEBOOK_SECRET;
_fbService.IsDesktopApplication = false;
_fbService.ConnectToFacebook();
abc.InnerText = _fbService.users.getInfo().ToString();
}
and it is throwing and Exception in the last line that that the object reference is not set.
You will need to host your production application somewhere, but you can test locally. If you set your Canvas URL to http://localhost:81 in Facebook, this should work. It did for me a couple of months ago, but they may have changed it since then.
this might be an interesting for you:
http://www.stevetrefethen.com/blog/DevelopingFacebookapplicationsinCwithASPNET.aspx

Web Application Project - how to use ProfileCommon

I am porting a site I had developed on an old box across to a new dev env. I have not just copied all the files as I didn't have a great file structure and some parts of the code needed to be removed as I went along.
Originally I had created a website (File -> New -> Web Site). I wanted a file structure something like:
Popular folder structure for build
So I created a new blank solution so the sln file was on its own, then added projects (various DLL projects) and am ASP.NET Web Application.
This last part seems to have caused me a few issues, I am now getting the following error:
"The type or namespace name ' ProfileCommon' could not be found".
I found the following page:
http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx
It seems a bit long winded and I was hoping someone might know of a better solution.
I am trying to use the ProfileCommon with the CreateUser Wizard as I add a little extra information into it.
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
// Create an empty Profile for the newly created user
ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true);
// Populate some Profile properties off of the create user wizard
p.CurrentLevel = Int32.Parse(((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("clevel")).SelectedValue);
// Save profile - must be done since we explicitly created it
p.Save();
}
Web.config:
<profile enabled="true">
<properties>
<add name="CurrentLevel" type="Int32"/>
</properties>
</profile>
If there is another way to add this extra information into the creation wizard, or just a better way of setting extra info to a new user then I am all ears and would be very grateful.
Thanks for the help and advice.
This is a very late post, but I just ran into this same problem when porting a VB.NET Visual Studio 2008 (.NET 3.5) website over to C# Visual Studio 2010 (.NET 4.0) website.
I found references to ProfileCommon in MSDN's ProfileBase documentation, but nothing on how to get that object.
From your helpful MSDN link, I noticed that ProfileCommon would only ever be just a wrapper for the HttpContext.
In short, I used the var keyword to extract the ProfileCommon information from the HttpContext, as in:
var profile = HttpContext.Current.Profile;
Using this one bit of information, I was able to create the entire class for reading and writing the information for my website visitors.
Like you, I hope this code might help someone else:
using System.Web;
using System.Web.Security;
namespace WebApplication17 {
public partial class ManageProfile : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
if (User.Identity.IsAuthenticated) {
loadProfile();
} else {
goHome();
}
}
}
private void changePassword(string pwdOld, string pwdNew) {
MembershipUser user = Membership.GetUser(User.Identity.Name);
user.ChangePassword(pwdOld, pwdNew);
Membership.UpdateUser(user);
}
private void goHome() {
Server.Transfer("Default.aspx");
}
private void loadProfile() {
MembershipUser user = Membership.GetUser(User.Identity.Name);
txtEmail.Text = user.Email;
TextBox3.Text = user.GetPassword();
var profile = HttpContext.Current.Profile;
txtTitle.Text = profile.GetPropertyValue("Title").ToString();
txtName.Text = profile.GetPropertyValue("Name").ToString();
txtAddress.Text = profile.GetPropertyValue("Address").ToString();
txtCity.Text = profile.GetPropertyValue("City").ToString();
txtSt.Text = profile.GetPropertyValue("St").ToString();
txtZip.Text = profile.GetPropertyValue("Zip").ToString();
txtPhone.Text = profile.GetPropertyValue("Phone").ToString();
txtFax.Text = profile.GetPropertyValue("Fax").ToString();
txtCompany.Text = profile.GetPropertyValue("Company").ToString();
}
private void setProfile() {
MembershipUser user = Membership.GetUser(User.Identity.Name);
user.Email = txtEmail.Text;
Membership.UpdateUser(user);
var profile = HttpContext.Current.Profile;
profile.SetPropertyValue("Title", txtTitle.Text);
profile.SetPropertyValue("Name", txtName.Text);
profile.SetPropertyValue("Address", txtAddress.Text);
profile.SetPropertyValue("City", txtCity.Text);
profile.SetPropertyValue("St", txtSt.Text);
profile.SetPropertyValue("Zip", txtZip.Text);
profile.SetPropertyValue("Phone", txtPhone.Text);
profile.SetPropertyValue("Fax", txtFax.Text);
profile.SetPropertyValue("Company", txtCompany.Text);
profile.Save();
}
protected void Button6_Click(object sender, EventArgs e) {
changePassword(TextBox3.Text, TextBox4.Text);
goHome();
}
protected void Button11_Click(object sender, EventArgs e) {
setProfile();
goHome();
}
}
}
I found "a" solution to this one. Not sure if it is the best one or not but it worked for my situation. Minimal code changes required.
http://msdn.microsoft.com/en-us/library/aa983476.aspx
Hope it might help someone else, (or me when I forget it again).

Categories