AppDelegateNotification 1.0.1

AppDelegateNotification 1.0.1

测试测试过
语言语言 Obj-CObjective C
许可 自定义
发布时间最后发布2015年5月

ateliee 维护。



  • ateliee

AppDelegateNotifitaion

推送通知类。支持 iOS7,8

安装

pod 文件添加

pod 'AppDelegateNotification'

添加 Notification 类

Notification.h

@interface Notification : NSObject<PushNotification> {
}

Notification.m

@implementation Notification

-(void) didRegistDeviceToken : (UIApplication *)application deviceToken:(NSString *)token{
    NSLog(@"Success : Regist to APNS.(%@)", token);
}
-(void) didFailRegistDeviceToken : (UIApplication *)application error:(NSError *)error{
    NSLog(@"Error : Fail Regist to APNS.(%@)",error);
}
-(void)setBadge:(UIApplication *)application number:(int)number
{
    if(number >= 1){
        application.applicationIconBadgeNumber = number;
    }else{
        application.applicationIconBadgeNumber = -1;
    }
}
-(void) didPushNotification : (UIApplication *)application userInfo:(NSDictionary *)userInfo{
}
@end

更改 AppDelegate

AppDelegate.h

@interface AppDelegate : AppDelegateNotification{
}

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    Notification *push = [[Notification alloc] init];
    [self initNotification:(PushNotificationTypeAlert | PushNotificationTypeBadge | PushNotificationTypeSound | PushNotificationTypeNewsstandContentAvailability) callback:push launchOptions:launchOptions background:TRUE];
    if (IS_SET(launchOptions,UIApplicationLaunchOptionsLocalNotificationKey)) {
        [application scheduleLocalNotification:launchOptions[UIApplicationLaunchOptionsLocalNotificationKey]];
    }
    return YES;
}