//
//  IOSNotification.m
//  rainbow
//
//  Created by Doha Tubaileh on 10/31/19.
//  Copyright © 2019 Facebook. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "IOSNotification.h"


@interface IOSNotification ()

@end

@implementation IOSNotification

+(id)sharedManager {
    static IOSNotification *sharedMyManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedMyManager = [[self alloc] init];
    });
    return sharedMyManager;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        
    }
    return self;
}

+(void)sendUserNotification:(NSString*)title notificationBody:(NSString*)msg iconBadgeNumber:(NSInteger)number {
    UILocalNotification *localNotification = [[UILocalNotification alloc] init];
    localNotification.fireDate = [[NSDate alloc] initWithTimeIntervalSinceNow:0];
    localNotification.alertBody = msg;
    localNotification.alertTitle = title;
    localNotification.timeZone = NSTimeZone.localTimeZone;
    localNotification.soundName = UILocalNotificationDefaultSoundName;
    if (number >= 0) {
        localNotification.applicationIconBadgeNumber = number;
    }
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}

@end
