コード例 #1
0
        //ADD THIS METHOD :

        public void NewMessageHandler(NSNotification obj)
        {
            int count = ALChatManager.GetUreadCount();

            Console.WriteLine("Unread count is {0}", count);
            this.UreadCount.Text = "Unread count : " + count;
        }
コード例 #2
0
        partial void OneToOneChatBtn_TouchUpInside(UIButton sender)
        {
            UIAlertController alert = UIAlertController.Create("Applozic Demo!!!", "Enter userId of receiver", UIAlertControllerStyle.Alert);

            alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, action =>
            {
                // This code is invoked when the user taps on login, and this shows how to access the field values
                Console.WriteLine("UserID: {0}", alert.TextFields[0].Text);
                String userId = alert.TextFields[0].Text;

                if (String.IsNullOrEmpty(userId))
                {
                    new UIAlertView("", "Please enter userId", null, "OK", null).Show();
                    return;
                }
                ALChatManager.launchChatForUser(userId, this);
            }));

            //Cancel
            alert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Default, action =>
            {
                Console.WriteLine("UserID: {0}", alert.TextFields[0].Text);
            }));

            alert.AddTextField((field) =>
            {
                field.Placeholder = "userId";
            });

            PresentViewController(alert, animated: true, completionHandler: null);
        }
コード例 #3
0
        partial void LoginButton_TouchUpInside(UIButton sender)
        {
            //Registration code here. Build your user details.
            ALUser user = new ALUser();

            user.ApplicationId = ALChatManager.application_id;
            user.UserId        = userIdTextField.Text;
            user.Password      = passwordTextField.Text;
            ALUserDefaultsHandler.SetPassword(user.Password);
            ALUserDefaultsHandler.SetUserAuthenticationTypeId((short)AuthenticationType.Applozic);

            //Applozic registartion code.
            ALRegisterUserClientService userClientService = new ALRegisterUserClientService();

            userClientService.InitWithCompletion(user, (ALRegistrationResponse response, NSError error) =>
            {
                if (error == null && response.DeviceKey != null)
                {
                    //Check for APNS deviceToken. If not done already, ask for registartion token.
                    if (String.IsNullOrEmpty(ALUserDefaultsHandler.ApnDeviceToken))
                    {
                        ALChatManager.registerNotification();
                    }

                    UIStoryboard Storyboard = UIStoryboard.FromName("Main", null);
                    MainViewController MainViewController = Storyboard.InstantiateViewController("MainViewController") as MainViewController;
                    this.PresentViewController(MainViewController, true, () => { });
                }
                else
                {
                    String description = error != null ? error.LocalizedDescription : response.Message;
                    new UIAlertView("Opps!!!", description, null, "OK", null).Show();
                }
            });
        }
コード例 #4
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            NSNotificationCenter notification = NSNotificationCenter.DefaultCenter;

            //notification.AddObserver(this, new Selector("newMessageHandler"),
            //                         (NSString) "newMessageNotification",null);
            this.UreadCount.Text = "Unread count : " + ALChatManager.GetUreadCount();
            notification.AddObserver((NSString)"newMessageNotification", NewMessageHandler);
        }
コード例 #5
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            NSNotificationCenter notification = NSNotificationCenter.DefaultCenter;

            //notification.AddObserver(this, new Selector("newMessageHandler"),
            //                         (NSString) "newMessageNotification",null);
            this.UreadCount.Text = "Unread count : " + ALChatManager.GetUreadCount();
            notification.AddObserver((NSString)"newMessageNotification", NewMessageHandler);
            if (this.NavigationController != null)
            {
                this.NavigationItem.SetLeftBarButtonItem(
                    new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (sender, args) =>
                {
                    this.DismissViewController(true, () => { });
                })
                    , false);
            }
        }
コード例 #6
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method


            if (ALUserDefaultsHandler.IsLoggedIn)
            {
                ALPushNotificationService.UserSync();
                // Get login screen from storyboard and present it
                UIStoryboard       Storyboard         = UIStoryboard.FromName("Main", null);
                MainViewController MainViewController = Storyboard.InstantiateViewController("MainViewController") as MainViewController;
                this.Window.MakeKeyAndVisible();
                this.Window.RootViewController.PresentViewController(MainViewController, true, () => { });
            }

            ALAppLocalNotifications localNotification = ALAppLocalNotifications.AppLocalNotificationHandler;

            localNotification.DataConnectionNotificationHandler();

            if (launchOptions != null)
            {
                NSDictionary dictionary = (Foundation.NSDictionary)launchOptions.ObjectForKey(UIApplication.LaunchOptionsRemoteNotificationKey);

                if (dictionary != null)
                {
                    Console.WriteLine(@"Launched from push notification: {0} ", dictionary);
                    ALPushNotificationService pushNotificationService = new ALPushNotificationService();
                    Boolean applozicProcessed = pushNotificationService.ProcessPushNotification(dictionary, 0);

                    if (!applozicProcessed)
                    {
                        //Note: notification for app
                    }
                }
            }

            ALChatManager.registerNotification();

            return(true);
        }
コード例 #7
0
 partial void Logout_TouchUpInside(UIButton sender)
 {
     ALChatManager.logout();
     this.DismissViewControllerAsync(false);
 }
コード例 #8
0
 partial void LaunchContextB_TouchUpInside(UIButton sender)
 {
     ALChatManager.launchContextBasedChat(createConversation(), this);
 }
コード例 #9
0
 partial void ChatListBtn_TouchUpInside(UIButton sender)
 {
     ALChatManager.launchChatList(this);
 }