JLChen
2021-08-02 38f4fb064df09f344fc3237409c76a9fba2a8a9e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
//  LoginInVC.m
//  VoipTest
//
//  Created by StevStark on 2020/11/18.
//
 
#import "LoginInVC.h"
#import "ViewController.h"
@interface LoginInVC ()
 
@end
 
@implementation LoginInVC
 
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [NSNotificationCenter.defaultCenter addObserver:self
                                           selector:@selector(registrationUpdate:)
                                               name:@"LinphoneRegistrationUpdate"
                                             object:nil];
}
 
- (void)viewDidDisappear:(BOOL)animated{
    [NSNotificationCenter.defaultCenter removeObserver:self];
}
 
- (void)registrationUpdate:(NSNotification *)notif {
    LinphoneRegistrationState state = [[notif.userInfo objectForKey:@"state"] intValue];
    if (state == LinphoneRegistrationFailed){
        [self.logView setText:@"登录失败"];
        
    } else if (state == LinphoneRegistrationOk) {
        UIStoryboard *board = [UIStoryboard storyboardWithName: @"Main" bundle: nil];
        
        ViewController *vc = [board instantiateViewControllerWithIdentifier: @"ViewController"];
        [self presentViewController:vc animated:true completion:nil];
//        
//        UIWindow *window = ((AppDelegate*)([UIApplication sharedApplication].delegate)).window;
//        [window setRootViewController:vc];
        
    }
}
 
 
- (IBAction)b_login:(id)sender {
//    [LinphoneManager.instance login:_t_account.text password:_t_pwd.text domain:_t_domain.text];
//    [LinphoneManager.instance login:@"1010" password:@"1234" domain:@"dnake.xswitch.cn:20401"];
//    [LinphoneManager.instance login:@"9999" password:@"85521566" domain:@"47.114.117.27:5060"];
    [LinphoneManager.instance login:@"2002" password:@"1234" domain:@"192.168.3.8:5060"];
    
}
 
 
@end