public async override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Create an HTTPClient object and use it to fetch
            // a capability token from our website.
            var client = new HttpClient();
            var token  = await client.GetStringAsync("http://localhost:8080/Client/Token");

            // Create a new TCDevice object passing in the token.
            _device = new TCDevice(token, null);
        }
コード例 #2
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            _device = new TCDevice("YOUR TWILIO TOKEN", null);

            SetupDeviceEvents();

            GlobalEvents.OnPhoneCall    += MainActivity_OnPhoneCall;
            GlobalEvents.OnPhoneHangout += MainActivity_OnPhoneHangout;
            GlobalEvents.OnMute         += GlobalEvents_OnMute;

            return(base.FinishedLaunching(app, options));
        }
コード例 #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            WebClient client = new WebClient();
            string    token  = client.DownloadString("http://devin.webscript.io/generateToken?ClientName=mono&TwimlApp=APd5e7f789da788fd4b1785353de3cfbf9");

//			device = new TCDevice(token,deviceDelegate);

            // HACK:
            // The delegate param should be null if you want to use events pattern instead of custom delegate pattern
            // this is because when you set up an event we internally will create a Objc delegate that will be assigned to the delegate property
            // and if we see that delegate property is not null then we will not be able to set you up

            // You might find this reading interesting
            // http://docs.xamarin.com/guides/ios/application_fundamentals/delegates%2C_protocols%2C_and_events

            device = new TCDevice(token, null);

            Console.WriteLine("Inbound: " + device.Capabilities["incoming"].ToString());
            Console.WriteLine("Outbound: " + device.Capabilities["outgoing"].ToString());

            updateStateLabels();
        }
コード例 #4
0
 public override void DidStopListeningForIncomingConnections(TCDevice device, NSError error)
 {
     //Console.WriteLine("DidStopListeningForIncomingConnection");
 }
コード例 #5
0
        public async override void FinishedLaunching(UIApplication application)
        {
            this.Window = new UIWindow(UIScreen.MainScreen.Bounds);

            var client = new HttpClient();
            var token  = await client.GetStringAsync("** Your AuthToken URL goes here **");

            device = new TCDevice(token, null);

            var dialogController = new DialogViewController(new RootElement("Twilio Client Test")
            {
                new Section("Call Options")
                {
                    (numberOrClient = new EntryElement("Target", "Phone # or client name", "")),
                    (callButton = new StyledStatusStringElement("Call", delegate {
                        if (connection == null || connection.State == TCConnectionState.Disconnected)
                        {
                            var param = new TCConnectionParameters {
                                Source = "** Your Twilio Phone Number goes here **",
                                Target = numberOrClient.Value
                            };

                            connection = device.Connect(param, null);

                            SetupConnectionEvents();
                        }
                        else
                        {
                            connection.Disconnect();
                        }
                    })),
                },
                new Section("Status")
                {
                    (deviceState = new StatusStringElement("Device", device.State.ToString())),
                    (connectionState = new StatusStringElement("Connection", "Uninitialized"))
                },

                new Section("Sounds")
                {
                    (disconnectSoundEnabled = new BooleanElement("Disconnect Sound", device.DisconnectSoundEnabled)),
                    (incomingCallSoundEnabled = new BooleanElement("Incoming Sound", device.IncomingSoundEnabled)),
                    (outgoingCallSoundEnabled = new BooleanElement("Outgoing Sound", device.OutgoingSoundEnabled))
                },

                new Section("Options")
                {
                    (muted = new BooleanElement("Muted", false)),
                    (listening = new BooleanElement("Device Listening", true))
                }
            });

            callButton.Alignment = UITextAlignment.Center;
            callButton.TextColor = UIColor.FromRGB(0x00, 0x7A, 0xFF);

            var navigationController = new UINavigationController(dialogController);

            //navigationController.NavigationBar.BarTintColor = UIColor.Red;
            //navigationController.NavigationBar.TintColor = UIColor.White;

            Window.RootViewController = navigationController;

            Window.MakeKeyAndVisible();

            SetupSoundOptionEvents();
            SetupOptions();
            SetupDeviceEvents();
            device.Listen();
        }