U
U
ungradable2017-04-17 16:15:07
Android
ungradable, 2017-04-17 16:15:07

Problem with vk sdk api, app.SendRequest method. How to properly configure this request?

Good day.
I am using vk api sdk in Xamarin.Android. I create a request like this:

var token = VKHelper.GetVkUserToken(App.Data.Setting.List);
var iparams = new Dictionary<string, Java.Lang.Object>();
iparams.Add(VKApiConst.UserId, VKBuffer.Friend.Id);
iparams.Add("type", "invite");
iparams.Add("access_token", token);
v = new VKRequest("apps.sendRequest", new VKParameters(iparams));

on button click I call ExecuteWithListener:
v.ExecuteWithListener(new ReqvList(new Action(o =>
{
if (o.IsComplete)
   {
      try
      {
           showCustomAlert(Resource.Drawable.checkmark, GetString(Resource.String.SentInvite), Android.Graphics.Color.Argb(100, 0, 0, 200));
      }
      catch { }
   }
   else
   {
       try
       {
           showCustomAlert(Resource.Drawable.ic_post, GetString(Resource.String.NotSentInvite) + "\n" + GetString(o.MessageId), Android.Graphics.Color.Argb(100, 200, 0, 0));
       }
       catch { }
   }
})));

As a result: if I click on the button to invite the user to the game, then the VKontakte dialog box will appear with a proposal to invite (there you can agree, you can cancel). If I click "invite" a user who in the settings forbade inviting himself to games, it will work fine, these are the lines:
....
else
{
try
{
showCustomAlert(Resource.Drawable.ic_post, GetString(Resource.String.NotSentInvite) + "\n" + GetString(o.MessageId), Android.Graphics.Color.Argb(100, 200, 0, 0));
}
catch { }
}

....
But if the user "allows" to invite him, then the "lisener" does not work and the application freezes. In the application, you can press the "back" button, the application will "hang" and, if I invite you again, everything will work. those. the licener works in case of the complete status only from the second time, these are the lines
...
if (o.IsComplete)
{
try
{
showCustomAlert(Resource.Drawable.checkmark, GetString(Resource.String.SentInvite), Android.Graphics.Color.Argb(100, 0, 0, 200));
}
catch { }
}

...
Everywhere it is written that you need to do it this way, but this solution does not work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
yomanx, 2017-06-27
@yomanx

Friend, how do you even accept requests sent via apps.sendRequest?
For example, I sent a gift to a friend, how will his friend receive it? what method?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question