本文整理汇总了C#中NSData类的典型用法代码示例。如果您正苦于以下问题:C# NSData类的具体用法?C# NSData怎么用?C# NSData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSData类属于命名空间,在下文中一共展示了NSData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisteredForRemoteNotifications
public override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
{
Task.Run (async () => {
var service = ServiceContainer.Resolve<APNSManager> ();
await service.RegisteredForRemoteNotificationsAsync (application, deviceToken);
});
}
示例2: SecCertificate
public SecCertificate(NSData data)
{
if (data == null)
throw new ArgumentNullException ("data");
Initialize (data);
}
示例3: RegisteredForRemoteNotifications
public async override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
this.deviceToken = deviceToken.ToString().Replace("<", "").Replace(">", "").Replace(" ", "");
var push = CommonAppSettings.MobileService.GetPush();
var employeeId = CommonAppSettings.FixedEmployeeId;
try
{
var jsonTemplate = "{\"aps\":{\"message\":\"$(message)\"}}";
var expiry = DateTime.Now.AddDays(90).ToString(CultureInfo.CreateSpecificCulture("en-US"));
await push.RegisterTemplateAsync(this.deviceToken, jsonTemplate, expiry, "MyShuttleTemplate",
new string[]
{
string.Format("VehicleApproved-{0}", employeeId),
string.Format("VehicleRejected-{0}", employeeId),
string.Format("VehicleArrived-{0}", employeeId)
});
}
catch (Exception e)
{
var userInteractionService = Mvx.Resolve<IUserInteraction>();
if (userInteractionService != null)
{
userInteractionService.Alert(e.Message, title: "Error registering notifications");
}
}
}
示例4: RegisteredForRemoteNotifications
public async override void RegisteredForRemoteNotifications (UIApplication application, NSData deviceToken)
{
ParseInstallation installation = ParseInstallation.CurrentInstallation;
installation.SetDeviceTokenFromData (deviceToken);
await ParsePush.SubscribeAsync ("");
await installation.SaveAsync ();
}
示例5: OnRegisteredSuccess
public void OnRegisteredSuccess(NSData token)
{
Debug.WriteLine("{0} - Succesfully Registered.", PushNotificationKey.DomainName);
string trimmedDeviceToken =token.Description;
if (!string.IsNullOrWhiteSpace(trimmedDeviceToken))
{
trimmedDeviceToken = trimmedDeviceToken.Trim('<');
trimmedDeviceToken = trimmedDeviceToken.Trim('>');
trimmedDeviceToken = trimmedDeviceToken.Trim();
trimmedDeviceToken = trimmedDeviceToken.Replace(" ","");
}
Console.WriteLine("{0} - Token: {1}", PushNotificationKey.DomainName, trimmedDeviceToken);
if (CrossPushNotification.IsInitialized)
{
CrossPushNotification.PushNotificationListener.OnRegistered(trimmedDeviceToken, DeviceType.iOS);
}
else
{
throw NewPushNotificationNotInitializedException();
}
NSUserDefaults.StandardUserDefaults.SetString(trimmedDeviceToken, PushNotificationKey.Token);
NSUserDefaults.StandardUserDefaults.Synchronize ();
}
示例6: ReceivedData
public override void ReceivedData (NSUrlConnection connection, NSData data)
{
if (_view.imageData==null)
_view.imageData = new NSMutableData();
_view.imageData.AppendData(data);
}
示例7: FromData
public static NSString FromData(NSData data, NSStringEncoding encoding)
{
// Allocate a string, do not init
IntPtr h = Messaging.IntPtr_objc_msgSend (Class.GetHandle ("NSString"), Selector.Alloc);
h = Messaging.IntPtr_objc_msgSend_IntPtr_int (h, selInitWithDataEncoding, data.Handle, (int)encoding);
return new NSString (h);
}
示例8: GetCell
public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
ImageTableCell cell = tableView.DequeueReusableCell(cellIdentifier) as ImageTableCell;
try
{
if (cell == null)
cell = new ImageTableCell(cellIdentifier, navigate.View.Bounds.Width);
NSData data = new NSData();
if (!String.IsNullOrEmpty(_urls[indexPath.Row]))
{
NSUrl nsUrl = new NSUrl(_urls[indexPath.Row]);
data = NSData.FromUrl(nsUrl);
}
cell.UpdateCell(new UIImage(data));
OnGotCell();
CellOn = indexPath.Row;
}
catch (Exception exception)
{
ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
}
return cell;
}
示例9: GetCell
public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
SkatersTableCell cell = tableView.DequeueReusableCell(cellIdentifier) as SkatersTableCell;
try
{
if (cell == null)
cell = new SkatersTableCell(cellIdentifier);
NSData data = new NSData();
if (!String.IsNullOrEmpty(tableItems[indexPath.Row].ThumbUrl))
{
NSUrl nsUrl = new NSUrl(tableItems[indexPath.Row].ThumbUrl);
data = NSData.FromUrl(nsUrl);
}
cell.UpdateCell(tableItems[indexPath.Row].DerbyName, tableItems[indexPath.Row].DerbyNumber, new UIImage(data));
OnGotCell();
CellOn = indexPath.Row;
}
catch (Exception exception)
{
ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
}
return cell;
}
示例10: ReceivedData
// Collect all the data
public override void ReceivedData (NSUrlConnection connection, NSData data)
{
byte [] nb = new byte [result.Length + data.Length];
result.CopyTo (nb, 0);
Marshal.Copy (data.Bytes, nb, result.Length, (int) data.Length);
result = nb;
}
示例11: Clicked
public override void Clicked(UIActionSheet actionview, int buttonIndex)
{
if (buttonIndex == 0)
{
Console.Write("Satya!!!!!!");
/*UIActivityIndicatorView spinner = new UIActivityIndicatorView(new RectangleF(0,0,200,300));
spinner.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.WhiteLarge;
spinner.Center= new PointF(160, 140);
spinner.HidesWhenStopped = true;
actionview.AddSubview(spinner);
InvokeOnMainThread(delegate() {
spinner.StartAnimating();
});
*/
var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
fileName = documents + "/" + fileName;
data = NSData.FromUrl(_nsurl);
File.WriteAllBytes(fileName,data.ToArray());
if (File.Exists(fileName))
{
UIAlertView alert = new UIAlertView();
alert.Title = "Download Complete";
alert.AddButton("Done");
alert.Show();
}
//spinner.StopAnimating();
}
}
示例12: RegisteredForRemoteNotifications
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
if (CrossPushNotification.Current is IPushNotificationHandler)
{
((IPushNotificationHandler)CrossPushNotification.Current).OnRegisteredSuccess(deviceToken);
}
}
示例13: RegisteredForRemoteNotifications
public override void RegisteredForRemoteNotifications(
UIApplication application, NSData deviceToken)
{
DonkyiOS.RegisteredForRemoteNotifications(
application,
deviceToken);
}
示例14: RegisteredForRemoteNotifications
/// <summary>
/// We succeeded in registering for notifications
/// </summary>
/// <param name="application"></param>
/// <param name="deviceToken"></param>
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
{
// Get current device token
var deviceTokenDesc = deviceToken.Description;
if (!string.IsNullOrWhiteSpace(deviceTokenDesc))
{
deviceTokenDesc = deviceTokenDesc.Trim('<').Trim('>').Replace(" ", "");
}
UserDialogs.Instance.Alert(deviceTokenDesc);
// Has the token changed?
if (!string.IsNullOrEmpty(deviceTokenDesc))
{
//Register the user on your server
DeviceToken apiToken = new DeviceToken
{
Token = deviceTokenDesc,
Device = Device.OS.ToString()
};
ApiService apiService = new ApiService();
apiService.PostAsync<DeviceToken>("Devices/Post", apiToken);
}
}
示例15: OnStatusUpdate
private void OnStatusUpdate(NSData data)
{
UserStatuses status;
if (Enum.TryParse(GetStringFromNSData(data), out status))
{
User.Status = status;
}
}