本文整理汇总了C#中NSDictionary.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# NSDictionary.ContainsKey方法的具体用法?C# NSDictionary.ContainsKey怎么用?C# NSDictionary.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSDictionary
的用法示例。
在下文中一共展示了NSDictionary.ContainsKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FinishedLaunching
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
#if DEBUG
Xamarin.Calabash.Start();
#endif
// create our window
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.MakeKeyAndVisible ();
home = new Screens.iPhone.Home.Home_iPhone();
home.View.Frame = new CoreGraphics.CGRect (0, UIApplication.SharedApplication.StatusBarFrame.Height, UIScreen.MainScreen.ApplicationFrame.Width, UIScreen.MainScreen.ApplicationFrame.Height);
window.RootViewController = home;
// check for a notification
if(options != null) {
// check for a local notification
if(options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey)) {
UILocalNotification localNotification = options[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
if(localNotification != null) {
new UIAlertView(localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show();
// reset our badge
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
}
}
// check for a remote notification
if(options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey)) {
NSDictionary remoteNotification = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
if(remoteNotification != null) {
//new UIAlertView(remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show();
}
}
}
if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes (
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
);
app.RegisterUserNotificationSettings (notificationSettings);
app.RegisterForRemoteNotifications ();
} else {
//==== register for remote notifications and get the device token
// set what kind of notification types we want
UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;
// register for remote notifications
UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
}
return true;
}
示例2: ProcessNotification
public static void ProcessNotification (NSDictionary options, bool fromFinishedLaunching)
{
//Check to see if the dictionary has the aps key. This is the notification payload you would have sent
if (options.ContainsKey (new NSString (Resources.Communication.ApsRootElement))) {
//Get the aps dictionary
var aps = options.ObjectForKey (new NSString (Resources.Communication.ApsRootElement)) as NSDictionary;
string alert = string.Empty;
string sound = string.Empty;
int badge = -1;
//Extract the alert text
//NOTE: If you're using the simple alert by just specifying " aps:{alert:"alert msg here"} "
// this will work fine. But if you're using a complex alert with Localization keys, etc., your "alert" object from the aps dictionary
// will be another NSDictionary... Basically the json gets dumped right into a NSDictionary, so keep that in mind
if (aps.ContainsKey (new NSString (Resources.Communication.ApsAlertElement))) {
//alert = (aps [new NSString (Resources.Communication.ApsAlertElement)] as NSString).ToString ();
alert = aps.ObjectForKey (new NSString (Resources.Communication.ApsAlertElement)).ToString ();
}
//Extract the sound string
if (aps.ContainsKey (new NSString (Resources.Communication.ApsSoundElement))) {
//sound = (aps [new NSString (Resources.Communication.ApsSoundElement)] as NSString).ToString ();
sound = aps.ObjectForKey (new NSString (Resources.Communication.ApsSoundElement)).ToString ();
}
//Extract the badge
if (aps.ContainsKey (new NSString (Resources.Communication.ApsBadgeElement))) {
//string badgeStr = (aps [new NSString (Resources.Communication.ApsBadgeElement)] as NSString).ToString ();
string badgeStr = aps.ObjectForKey (new NSString (Resources.Communication.ApsBadgeElement)).ToString ();
int.TryParse (badgeStr, out badge);
}
//If this came from the ReceivedRemoteNotification while the app was running,
// we of course need to manually process things like the sound, badge, and alert.
if (!fromFinishedLaunching) {
//Manually set the badge in case this came from a remote notification sent while the app was open
if (badge >= 0)
UIApplication.SharedApplication.ApplicationIconBadgeNumber = badge;
/*
//Manually play the sound
if (!string.IsNullOrEmpty (sound)) {
//This assumes that in your json payload you sent the sound filename (like sound.caf)
// and that you've included it in your project directory as a Content Build type.
var soundObj = MonoTouch.AudioToolbox.SystemSound.FromFile (sound);
soundObj.PlaySystemSound ();
}
*/
//Manually show an alert
if (!string.IsNullOrEmpty (alert)) {
using (UIAlertView avAlert = new UIAlertView ("Notification", alert, null, "OK", null)) {
avAlert.Show ();
}
}
}
}
}
示例3: OnMessageReceived
public void OnMessageReceived(NSDictionary userInfo)
{
var parameters = new Dictionary<string, object>();
var json = DictionaryToJson(userInfo);
JObject values = JObject.Parse(json);
var keyAps = new NSString("aps");
if (userInfo.ContainsKey(keyAps))
{
NSDictionary aps = userInfo.ValueForKey(keyAps) as NSDictionary;
if (aps != null)
{
foreach (var apsKey in aps)
{
parameters.Add(apsKey.Key.ToString(), apsKey.Value);
JToken temp;
if (!values.TryGetValue(apsKey.Key.ToString(), out temp))
values.Add(apsKey.Key.ToString(), apsKey.Value.ToString());
}
}
}
CrossPushNotification.PushNotificationListener.OnMessage(values, DeviceType.iOS);
}
示例4: FinishedLaunching
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
viewController = new CW_IOS_SingleViewApplicationViewController ();
window.RootViewController = viewController;
window.MakeKeyAndVisible ();
// check for a notification
if (options != null)
{
// check for a local notification
if (options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
{
var localNotification = options[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
if (localNotification != null)
{
new UIAlertView(localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show();
// reset our badge
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
}
}
}
return true;
}
示例5: FinishedLaunching
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
{
var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null
);
application.RegisterUserNotificationSettings(notificationSettings);
}
// check for a notification
if (launchOptions != null)
{
// check for a local notification
if (launchOptions.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
{
var localNotification = launchOptions[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
if (localNotification != null)
{
UIAlertController okayAlertController = UIAlertController.Create(localNotification.AlertAction, localNotification.AlertBody, UIAlertControllerStyle.Alert);
okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
Window.RootViewController.PresentViewController(okayAlertController, true, null);
// reset our badge
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
}
}
}
return true;
}
示例6: FinishedLaunching
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
// check for a notification
if (launchOptions != null)
{
// check for a local notification
if (launchOptions.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
{
var localNotification = launchOptions[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
if (localNotification != null)
{
new UIAlertView(localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show();
// reset our badge
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
}
}
}
// iOS 7
//UIApplication.SharedApplication.RegisterForRemoteNotificationTypes (UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge);
// iOS 8
var settings = UIUserNotificationSettings.GetSettingsForTypes(
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
, null);
UIApplication.SharedApplication.RegisterUserNotificationSettings (settings);
UIApplication.SharedApplication.RegisterForRemoteNotifications ();
return true;
}
示例7: FinishedLaunching
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
//UserDialogs.Init();
global::Xamarin.Forms.Forms.Init();
Insights.Initialize("0d729b1f8027a9219421908d521e3af664ae52fc");
PushNotificationManager pushmanager = PushNotificationManager.PushManager;
pushmanager.Delegate = this;
if (options != null)
{
if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
{
pushmanager.HandlePushReceived(options);
}
}
pushmanager.RegisterForPushNotifications();
try
{
var token = PushNotificationManager.PushManager.GetPushToken;
if (!String.IsNullOrEmpty(token))
App.PushWooshToken = token;
}
catch (Exception ex)
{
Insights.Report(ex);
}
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
示例8: FinishedLaunching
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
viewController = new PushwooshSampleViewController ();
window.RootViewController = viewController;
window.MakeKeyAndVisible ();
PushNotificationManager pushmanager = PushNotificationManager.PushManager;
pushmanager.Delegate = this;
if (options != null) {
if (options.ContainsKey (UIApplication.LaunchOptionsRemoteNotificationKey)) {
pushmanager.HandlePushReceived (options);
}
}
pushmanager.RegisterForPushNotifications ();
pushmanager.StartLocationTracking ();
Console.WriteLine("HWID: " + pushmanager.GetHWID);
return true;
}
示例9: FinishedLaunching
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
#if DEBUG
#else
//TestFlight.TakeOff ("ac104b5ca4df6cdfc5b9c63eb448f2af_NjMyMDYyMDEyLTAyLTE2IDExOjE5OjQ4LjkxMjI3Mw");
#endif
#region Notification
// check for a notification
if (options != null) {
/*
// check for a local notification
if (options.ContainsKey (UIApplication.LaunchOptionsLocalNotificationKey)) {
UILocalNotification localNotification = options [UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
if (localNotification != null) {
new UIAlertView (localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show ();
// reset our badge
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
}
}
*/
// check for a remote notification
if (options.ContainsKey (UIApplication.LaunchOptionsRemoteNotificationKey)) {
NSDictionary remoteNotification = options [UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
if (remoteNotification != null) {
//new UIAlertView(""Notification, remoteNotification["alert"], null, "OK", null).Show();
//PushNotifications.ProcessNotification (options, true);
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
}
}
}
//PushNotifications.Subscribe ();
#endregion
this.window = new UIWindow (UIScreen.MainScreen.Bounds);
//---- instantiate a new home screen
RootViewController rootController = new RootViewController ();
//---- instantiate a new navigation controller
this.rootNavigationController = new BaseNavigationController (rootController);
//---- add the home screen to the navigation controller
// (it'll be the top most screen)
//this.rootNavigationController.PushViewController (rootController, false);
//---- set the root view controller on the window. the nav
// controller will handle the rest
this.window.RootViewController = this.rootNavigationController;
this.window.MakeKeyAndVisible ();
//showSplash (rootController);
showSplashScreen ();
return true;
}
示例10: FinishedLaunching
public override bool FinishedLaunching(UIApplication application, NSDictionary options)
{
// Override point for customization after application launch.
// If not required for your application you can safely delete this method
if (IoC.Dbconnect == null)
{
IoC.Dbconnect = new DatabaseConnection();
InitSyncTables();
}
if (IoC.EventFactory == null)
{
IoC.EventFactory = new EventFactory();
}
if (IoC.ViewRefresher == null)
{
IoC.ViewRefresher = new ViewRefresher();
}
if (IoC.EmployeeFactory == null)
{
IoC.EmployeeFactory = new EmployeeFactory();
}
if (IoC.RecipientListFactory == null)
{
IoC.RecipientListFactory = new RecipientListFactory();
}
if (IoC.UserInfo == null)
{
IoC.UserInfo = new UserInfo();
}
SQLitePCL.CurrentPlatform.Init();
var settings = UIUserNotificationSettings.GetSettingsForTypes(
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null);
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
if (options != null)
{
// check for a local notification
if (options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey))
{
var localNotification = options[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
if (localNotification != null)
{
UIAlertController okayAlertController = UIAlertController.Create(localNotification.AlertAction, localNotification.AlertBody, UIAlertControllerStyle.Alert);
okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
ParentController.getNavigationMenu().ViewControllers[0].PresentViewController(okayAlertController, true, null);
// reset our badge
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
}
}
}
return true;
}
示例11: FinishedLaunching
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
// create our window
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.MakeKeyAndVisible ();
home = new Screens.iPhone.Home.Home_iPhone ();
home.View.Frame = new System.Drawing.RectangleF (0, UIApplication.SharedApplication.StatusBarFrame.Height, UIScreen.MainScreen.ApplicationFrame.Width, UIScreen.MainScreen.ApplicationFrame.Height);
window.RootViewController = home;
// check for a notification
if (options != null) {
// check for a local notification
if (options.ContainsKey (UIApplication.LaunchOptionsLocalNotificationKey)) {
UILocalNotification localNotification = options [UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification;
if (localNotification != null) {
new UIAlertView (localNotification.AlertAction, localNotification.AlertBody, null, "OK", null).Show ();
// reset our badge
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
}
}
// check for a remote notification
if (options.ContainsKey (UIApplication.LaunchOptionsRemoteNotificationKey)) {
NSDictionary remoteNotification = options [UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
if (remoteNotification != null) {
//new UIAlertView(remoteNotification.AlertAction, remoteNotification.AlertBody, null, "OK", null).Show();
}
}
}
//==== register for remote notifications and get the device token
// set what kind of notification types we want
UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;
// register for remote notifications
UIApplication.SharedApplication.RegisterForRemoteNotificationTypes (notificationTypes);
//
return true;
}
示例12: FinishedLaunching
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
NotificarePushLib.Shared().Launch ();
_pushLibDelegate = new MyPushLibDelegate ();
NotificarePushLib.Shared ().Delegate = _pushLibDelegate;
if (options != null && options.ContainsKey( UIApplication.LaunchOptionsRemoteNotificationKey ) )
{
NotificarePushLib.Shared().HandleOptions (options [UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary);
}
return true;
}
示例13: FinishedLaunching
/// <summary>
/// Finished the launching.
/// </summary>
/// <param name="app">The app.</param>
/// <param name="options">The options.</param>
/// <returns>True or false.</returns>
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
var iRate = MTiRate.iRate.SharedInstance;
iRate.AppStoreID = 707173885;
this.window = new UIWindow(UIScreen.MainScreen.Bounds);
var presenter = new TouchViewPresenter(this.window);
var setup = new Setup(this, presenter);
setup.Initialize();
Mvx.Resolve<CodeFramework.Core.Services.IErrorService>().Init("http://sentry.dillonbuchanan.com/api/5/store/", "17e8a650e8cc44678d1bf40c9d86529b ", "9498e93bcdd046d8bb85d4755ca9d330");
// Setup theme
Theme.Setup();
if (options != null)
{
if (options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
{
var remoteNotification = options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
if(remoteNotification != null) {
HandleNotification(remoteNotification, true);
}
}
}
var startup = Mvx.Resolve<IMvxAppStart>();
startup.Start();
this.window.MakeKeyAndVisible();
InAppPurchases.Instance.PurchaseError += HandlePurchaseError;
InAppPurchases.Instance.PurchaseSuccess += HandlePurchaseSuccess;
var features = Mvx.Resolve<IFeaturesService>();
// Automatic activations in debug mode!
#if DEBUG
Mvx.Resolve<CodeFramework.Core.Services.IDefaultValueService>().Set(FeatureIds.PushNotifications, true);
#endif
// Notifications don't work on teh simulator so don't bother
if (MonoTouch.ObjCRuntime.Runtime.Arch != MonoTouch.ObjCRuntime.Arch.SIMULATOR && features.IsPushNotificationsActivated)
{
const UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge;
UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
}
return true;
}
示例14: FinishedLaunching
public override bool FinishedLaunching(UIApplication application, NSDictionary options)
{
if(options != null) {
if(options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey)) {
// was woken from Local notification
var localNotification =
options[UIApplication.LaunchOptionsLocalNotificationKey] as
UILocalNotification;
if(localNotification != null)
ReceivedLocalNotification(localNotification);
}
else if(options.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey)) {
var remoteNotification =
options[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
if(remoteNotification != null)
ReceivedRemoteNotification(remoteNotification);
}
}
return true;
}
示例15: FinishedLaunching
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
PushNotificationManager pushmanager = PushNotificationManager.PushManager;
pushmanager.Delegate = this;
if (options != null) {
if (options.ContainsKey (UIApplication.LaunchOptionsRemoteNotificationKey)) {
var data = (NSDictionary)options.ValueForKey (UIApplication.LaunchOptionsRemoteNotificationKey);
HandleRemoteNotification (data, true);
}
}
return true;
}