I need to collect internet usage information on the iphone, the code in C # below that I'm using only returns me zero values.
Am I using the right class?
Is there any reference I need to add in xamarin?
In mono I get 3 types of classes, the interface "MacOsIPv4InterfaceStatistics" always returns a value of 0.
MacOsIPv4InterfaceStatistics
using System;
using System.Net;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
using System.Threading;
using MonoTouch.ObjCRuntime;
namespace Taximeter { public delegate void Update ();
public static class ControleUso
{
public static long controller;
public static long BytesReceivedWiFi;
public static long BytesSentWiFi;
public static long BytesReceived3G;
public static long BytesSent3G;
public static Update UpdateMethod;
public static void DoWork()
{
foreach (var netint in NetworkInterface.GetAllNetworkInterfaces()) {
var stats = netint.GetIPv4Statistics ();
//WiFi
//if (netint.Name.StartsWith ("en")) {
BytesReceivedWiFi += stats.BytesReceived;
BytesSentWiFi += stats.BytesSent;
//}
//3G
if (netint.Name.StartsWith ("pdp_ip")) {
BytesReceived3G += stats.BytesReceived;
BytesSent3G += stats.BytesSent;
}
}
controller++;
if (UpdateMethod != null) {
UpdateMethod ();
}
Thread.Sleep (1000);
}
}
}