How to use google analytics for win phone - c#

I have a win phone and I got a new requirement to put google analytic to log app events.
I added everything I found over net but my client saying that he is not seeing any log. So what I using is
GoogleAnalytics.EasyTracker.GetTracker().SetStartSession(true);
Used this line of code on app startup. And than
public void SendEvent(string category, string action, string label, int value)
{
GoogleAnalytics.EasyTracker.GetTracker().SendEvent(category, action, label, value);
}
this method to log events. Is there something wrong I am doing?

Related

Xamarin.Mac handle incoming URLs

I have added url in my Info.plist and trying to handle incoming url like described in this article.
I'm trying to add this code
public override void WillFinishLaunching(NSNotification notification)
{
NSAppleEventManager.SharedAppleEventManager.SetEventHandler(this, new ObjCRuntime.Selector("handleGetURLEvent:withReplyEvent:"), AEEventClass.Internet, AEEventID.GetUrl);
}
[Export("handleGetURLEvent:withReplyEvent:")]
private void HandleGetURLEvent(NSAppleEventDescriptor descriptor, NSAppleEventDescriptor replyEvent)
{
Logger.Info("Calling url on running app");
}
It all works fine, when my application is launched and somebody clicks on a URL (containing this custom scheme).
However, in the case, if my app isn't started then system start is (which is good). Unfortunately, handleGetURL() isn't called.

Selecting web element with id in appium test started using AndroidDriver

I'm new to Appium and testing as a whole. I used Android driver to test an app in android.
I can handle all clicks and typing in the app. But the issue arises while using the OAuth service to log in the app.
I use the following Driver client. appium dotnet driver
The login service opens in a separate chrome browser. I have to type text in an input element inside the web page.
I use the following code. On debugging page resource only has the android elements of the chrome browser and nothing of the web content.
var appiumDriver = new AndroidDriver<AndroidElement>(driverUri, appiumOptions);
[Test()]
[Order(1)]
public async Task TestLogin()
{
try
{
appiumDriver.FindElementByAccessibilityId("Login").Click();
await Task.Delay(3000);
var source = appiumDriver.PageSource;
var element = appiumDriver.FindElementById("login-email");
}
catch (NoSuchElementException ex)
{
}
}
Can anyone suggest how to proceed with this problem? This also has to be done in iOS, I guess both can be handled the same way.. Thanks in advance.
The issue was not changing to web context for searching in web page. The test flow had to be
Perform action to open the web page from the app. (In my case clicking login button)
Wait till the web page appears. (This is important as the web context will be available only after the web page appears) For this, I used a FindElementByClassName for a unique control visible in the web page but not on the previous App page. There sure can be a better way.
Get available contexts and switch to web context.
I used FindByCssSelector for finding the element with id.
Changing to web context
public static void ChangeToWebContext()
{
if (driver.Context != "NATIVE_APP")
return;
var elements = driver.FindElementByClassName("android.widget.EditText");
var availableContext = driver.Contexts;
if (availableContext.Count >= 2)
{
driver.Context = availableContext[1];
return;
}
}
Usgae:
this.ChangeToWebContext();
driver.FindElementByCssSelector("#login-password");

How to delete event in Google Calendar using API v3 .NET?

I have this method:
public static void DeleteEvent(CalendarService service, Event eventToDelete, string calendarId = "primary")
{
service.Events.Delete(calendarId, eventToDelete.Id);
}
but it's failing to delete any events from the calendar.
What's am I doing wrong?
What you need to do is Add an .Execute() at the End of the line to execute the delete command, then it will be like the following:
service.Events.Delete(calendarId, eventToDelete.Id).Execute();
You can refer this article as well for more informations

forcing to ignore some url parameters

I am making an iPhone app where I am using .NET webservice.
Let's say below is the URL I have.
http://www.myweb.com/wser.asmx/listOfStudents?class=12
Here I was getting list of students with below fields in it.
Name
Roll Number
Class
Now client asked to make arabic version. So we update the query to below.
http://www.myweb.com/wser.asmx/listOfStudents?class=12&appLang=ar
^^^^^^^^^^^^
For testing we update webservice on another server & checked and all is working fine.
Now while uploading app on App store, I noticed if I update actual webservice current app won't work as appLang variable is missing in current app that is there on app store.
If I don't update webservice & apple go in testing, the app will crash as it will throw error of missing parameter appLang.
So what I was thinking is,
I will upload new webservice, BUT appLang will be arabic BY-DEFAULT.
Like if I execute url http://www.myweb.com/wser.asmx/listOfStudents?class=12 with updated webservice (appLang added in webservice but not in url), it will not throw error of parameter missing appLang?
Is there any way to make default parameter?
while using GET isn't that pretty in this case (POST could be more suitable), you could do this :
//by specifying a messageName, you can do overloading with webmethods
[WebMethod (MessageName = "listOfStudentsDefault")]
[ScriptMethod(UseHttpGet=true)]
public string listOfStudents(int class, string appLang)
{
// code here...
}
[WebMethod (MessageName = "listOfStudents")]
[ScriptMethod(UseHttpGet=true)]
public string listOfStudents(int class)
{
return listOfStudents(class, "ar");
}

Xamarin/Mvvmcross: Open a different view controller when a iOS push notification is received

I have found this question asked using Objective-c but I am unable to translate it into C#
e.g.
open-specific-view-when-opening-app-from-notification
Basically I want to do this:
public override void ReceivedRemoteNotification (UIApplication application, NSDictionary userInfo)
{
string alert = (aps[new NSString("alert")] as NSString).ToString();
Debug.WriteLine ("I want to open a specific ViewController and pass in my alert");
}
I am actually using mvvmcross to manage my View navigation. So ideally I want to somehow implement this navigation using mvvmcross. In mvvmcross I would navigate to my ViewControler by doing this:
this.ShowViewModel<SpecificControllerViewModel>();
Thanks
if you look to the parameters of ShowViewModel(), it has a way to pass values to the view-model
this is described here along with examples
You can achieve that in few ways.
You could use a custom message. A view-model can register to receive the message and you send it from the ReceivedRemoteNotification Read here about messenger in MvvmCross.
Or, you can call ShowViewModel. If you look to how ShowViewModel is implemented here, it uses a IMvxViewDispatcher singleton service, so you could have the following utility method:
static void ShowViewModel<T>(object parameter) where T : IMvxViewModel
{
var viewDispatcher = Mvx.Resolve<IMvxViewDispatcher>();
var request = MvxViewModelRequest.GetDefaultRequest(typeof(T));
request.ParameterValues = ((object)parameter).ToSimplePropertyDictionary();
viewDispatcher.ShowViewModel(request);
}
I posted about this on my blog here.
I think the 2nd way can work even in the case when the notification is received when app is not running (received by FinishedLaunching)

Categories

Resources