61 lines
1.7 KiB
Objective-C
61 lines
1.7 KiB
Objective-C
//
|
|
// EQNLogViewController.m
|
|
// Earthquake Network
|
|
//
|
|
// Created by Luca Beretta on 01/12/18.
|
|
// Copyright © 2018 Luca Beretta. All rights reserved.
|
|
//
|
|
|
|
#import "EQNLogViewController.h"
|
|
#import "EQNManager.h"
|
|
#import "EQNAccelerometroManager.h"
|
|
#import "EQNUser.h"
|
|
|
|
@interface EQNLogViewController ()
|
|
@property (weak, nonatomic) IBOutlet UITextView *logView;
|
|
@property (nonatomic, strong) NSString *testo;
|
|
@end
|
|
|
|
@implementation EQNLogViewController
|
|
|
|
#pragma mark - View Lifecycle
|
|
|
|
- (void)viewDidLoad
|
|
{
|
|
[super viewDidLoad];
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aggiornaLog:) name:EQNDebugLogWillUpdateNotification object:nil];
|
|
|
|
[[EQNManager defaultManager] avviaManager];
|
|
[[EQNAccelerometroManager sharedInstance] startUpdatingLocationBackground];
|
|
|
|
self.testo = [NSString stringWithFormat:@" LOG ID UTENTE %@\n\nTOKEN FIREBASE:\n%@\n\n", [EQNUser defaultUser].user_ID, EQNUserData.sharedData.firebaseToken];
|
|
|
|
self.logView.text = self.testo;
|
|
}
|
|
|
|
#pragma mark - Actions
|
|
|
|
- (IBAction)chiudi:(id)sender
|
|
{
|
|
[[EQNManager defaultManager] stopManager];
|
|
[[EQNAccelerometroManager sharedInstance] stopUpdatingLocation];
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
}
|
|
|
|
#pragma mark - Notifications
|
|
|
|
- (void)aggiornaLog:(NSNotification *)notificaton
|
|
{
|
|
NSDictionary *messaggio = notificaton.userInfo;
|
|
NSString *messagioString = messaggio[@"messaggio"];
|
|
NSString *mes = self.logView.text;
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
self.logView.text = [NSString stringWithFormat:@"%@\n%@", mes, messagioString];
|
|
});
|
|
}
|
|
@end
|