public void BoardingPass()
        {
            if (UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Phone)
            {
                Assert.Inconclusive("PassKit does not work on iPads");
            }

            using (var pass = PassTest.GetBoardingPass())
                using (var ctrl = new PKAddPassesViewController(pass)) {
                    ctrl.Finished += delegate { };
                    // not available on iPad...
                    Assert.True((ctrl.Delegate != null) == PKPassLibrary.IsAvailable, "Delegate");
                    Assert.True((ctrl.WeakDelegate != null) == PKPassLibrary.IsAvailable, "WeakDelegate");
                }
        }
Пример #2
0
        public void InitWithNibNameTest()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion (7,0))
                Assert.Inconclusive ("initWithNibName:bundle: returns nil in iOS 6");

            if (UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Phone)
                Assert.Inconclusive ("PassKit does not work on iPads");

            PKAddPassesViewController ctrl = new PKAddPassesViewController (null, null);
            Assert.NotNull (ctrl, "PKAddPassesViewController ctor(String, NSBundle)");

            ctrl.Finished += delegate { };
            Assert.True ((ctrl.Delegate != null) == PKPassLibrary.IsAvailable, "Delegate");
            Assert.True ((ctrl.WeakDelegate != null) == PKPassLibrary.IsAvailable, "WeakDelegate");
        }
Пример #3
0
        public void BoardingPass()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion (6,0))
                Assert.Inconclusive ("PassKit is new in 6.0");

            if (UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Phone)
                Assert.Inconclusive ("PassKit does not work on iPads");

            using (var pass = PassTest.GetBoardingPass ())
            using (var ctrl = new PKAddPassesViewController (pass)) {
                ctrl.Finished += delegate { };
                // not available on iPad...
                Assert.True ((ctrl.Delegate != null) == PKPassLibrary.IsAvailable, "Delegate");
                Assert.True ((ctrl.WeakDelegate != null) == PKPassLibrary.IsAvailable, "WeakDelegate");
            }
        }
        public void InitWithNibNameTest()
        {
            // initWithNibName:bundle: returns nil in iOS 6
            TestRuntime.AssertSystemVersion(PlatformName.iOS, 7, 0, throwIfOtherPlatform: false);

            if (UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Phone)
            {
                Assert.Inconclusive("PassKit does not work on iPads");
            }

            PKAddPassesViewController ctrl = new PKAddPassesViewController(null, null);

            Assert.NotNull(ctrl, "PKAddPassesViewController ctor(String, NSBundle)");

            ctrl.Finished += delegate { };
            Assert.True((ctrl.Delegate != null) == PKPassLibrary.IsAvailable, "Delegate");
            Assert.True((ctrl.WeakDelegate != null) == PKPassLibrary.IsAvailable, "WeakDelegate");
        }
        public void InitWithNibNameTest()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(7, 0))
            {
                Assert.Inconclusive("initWithNibName:bundle: returns nil in iOS 6");
            }

            if (UIDevice.CurrentDevice.UserInterfaceIdiom != UIUserInterfaceIdiom.Phone)
            {
                Assert.Inconclusive("PassKit does not work on iPads");
            }

            PKAddPassesViewController ctrl = new PKAddPassesViewController(null, null);

            Assert.NotNull(ctrl, "PKAddPassesViewController ctor(String, NSBundle)");

            ctrl.Finished += delegate { };
            Assert.True((ctrl.Delegate != null) == PKPassLibrary.IsAvailable, "Delegate");
            Assert.True((ctrl.WeakDelegate != null) == PKPassLibrary.IsAvailable, "WeakDelegate");
        }
Пример #6
0
        void HandleAddTouchUpInside(object sender, EventArgs e)
        {
            if (PKPassLibrary.IsAvailable)
            {
                var documentsPath   = Environment.GetFolderPath(Environment.SpecialFolder.Personal);                // Documents folder
                var newFilePath     = Path.Combine(documentsPath, "CouponBanana2.pkpass");
                var builtInPassPath = Path.Combine(System.Environment.CurrentDirectory, "CouponBanana2.pkpass");
                if (!System.IO.File.Exists(newFilePath))
                {
                    System.IO.File.Copy(builtInPassPath, newFilePath);
                }

                NSData nsdata;
                using (FileStream oStream = File.Open(newFilePath, FileMode.Open)) {
                    nsdata = NSData.FromStream(oStream);
                }

                var err     = new NSError(new NSString("42"), -42);
                var newPass = new PKPass(nsdata, out err);

                bool alreadyExists = library.Contains(newPass);

                if (alreadyExists)
                {
                    new UIAlertView(newPass.LocalizedDescription + " Tapped"
                                    , "Already exists", null, "OK", null).Show();
                }
                else
                {
//					new UIAlertView(newPass.LocalizedDescription + " Tapped"
//					                , "Isn't in Pass Library", null, "OK, add it", null).Show();

                    var pkapvc = new PKAddPassesViewController(newPass);
                    NavigationController.PresentModalViewController(pkapvc, true);
                }
            }
        }
Пример #7
0
		void HandleAddTouchUpInside (object sender, EventArgs e)
		{
			if (PKPassLibrary.IsAvailable) {

				var documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
				var newFilePath = Path.Combine (documentsPath, "CouponBanana2.pkpass");
				var builtInPassPath = Path.Combine (System.Environment.CurrentDirectory, "CouponBanana2.pkpass");
				if (!System.IO.File.Exists(newFilePath))
					System.IO.File.Copy (builtInPassPath, newFilePath);

				NSData nsdata;
				using ( FileStream oStream = File.Open (newFilePath, FileMode.Open ) ) {
					nsdata = NSData.FromStream ( oStream );
				}

				var err = new NSError(new NSString("42"), -42);
				var newPass = new PKPass(nsdata,out err);

				bool alreadyExists = library.Contains (newPass);

				if (alreadyExists) {
					new UIAlertView(newPass.LocalizedDescription + " Tapped"
					                , "Already exists", null, "OK", null).Show();
				} else {
//					new UIAlertView(newPass.LocalizedDescription + " Tapped"
//					                , "Isn't in Pass Library", null, "OK, add it", null).Show();

					var pkapvc = new PKAddPassesViewController(newPass);
					NavigationController.PresentModalViewController (pkapvc, true);
				}
			}
		}