Skip to content

Instantly share code, notes, and snippets.

using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Threading.Tasks;
namespace BasicTable {
public class TableSource : UITableViewSource {
protected string[] tableItems;
protected string cellIdentifier = "TableCell";
@dannycabrera
dannycabrera / gist:6802931
Created October 3, 2013 00:58
Xamarin.iOS URL schema to link to app's iTunes App Store page
UIApplication.SharedApplication.OpenUrl(new NSUrl("itms-apps://itunes.apple.com/app/idAPP_ID"))
@dannycabrera
dannycabrera / Xamarin.iOS Get system version
Created October 3, 2013 14:22
Xamarin.iOS check for system version iOS 7
int SystemVersion = Convert.ToInt16(UIDevice.CurrentDevice.SystemVersion.Split ('.') [0].ToString ());
if (SystemVersion >= 7) {
this.EdgesForExtendedLayout = UIRectEdge.None;
this.AutomaticallyAdjustsScrollViewInsets = false;
this.ExtendedLayoutIncludesOpaqueBars = false;
}
or
async void Demo ()
{
switch (await ShowAlert ("Title", "Message", "Ok", "Cancel")){
case 0: // Ok
....
case 1: // Cancel
....
}
}
@dannycabrera
dannycabrera / Xamarin.iOS GetSSID
Created November 8, 2013 14:30
Xamarin.iOS GetSSID
public static string GetSSID(bool withMacAddress = true)
{
try {
NSDictionary dict;
var status = CaptiveNetwork.TryCopyCurrentNetworkInfo ("en0", out dict);
if (status == StatusCode.NoKey)
return "";
var bssid = dict [CaptiveNetwork.NetworkInfoKeyBSSID];
@dannycabrera
dannycabrera / AppDelegate
Created December 5, 2013 04:39
AudioQueueOfflineRenderDemo AppDelegate test
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using MonoTouch;
using MonoTouch.AVFoundation;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
@dannycabrera
dannycabrera / AppDelegate ReceivedRemoteNotification
Created March 25, 2014 19:32
AppDelegate ReceivedRemoteNotification Example
public override void ReceivedRemoteNotification (UIApplication application, NSDictionary userInfo)
{
processNotification(userInfo, false);
}
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 (null != options && options.ContainsKey(new NSString("aps")))
{
@dannycabrera
dannycabrera / Send MMS with Image Attachment using Xamarin.iOS
Created May 30, 2014 16:34
Send MMS with Image Attachment using Xamarin.iOS
//Source: http://davidsonblake.wordpress.com/2014/05/29/send-mms-with-image-attachment-using-xamarin-ios/
void SendMMS ()
{ //Init View Controller
var messageController = new MFMessageComposeViewController ();
//Verify app can send text message
if(MFMessageComposeViewController.CanSendText)
{
messageController.Body = "Here's an image for u 2 n joy.";
@dannycabrera
dannycabrera / gist:91360a81c182cfa30dac
Created December 2, 2014 02:08
Register for iOS 8 Notifications
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
UIUserNotificationType notificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
var settings = UIUserNotificationSettings.GetSettingsForTypes(notificationTypes, new NSSet (new string[] {}));
UIApplication.SharedApplication.RegisterUserNotificationSettings (settings);
UIApplication.SharedApplication.RegisterForRemoteNotifications ();
return true;
}
@dannycabrera
dannycabrera / AppDelegate.cs
Created December 30, 2015 22:20
Xamarin.iOS Blur screen with OnResignActivation
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
UIVisualEffectView _blurView = null;
public override void OnActivated (UIApplication application)
{
try {
if (_blurView != null) {
_blurView.RemoveFromSuperview ();