PushNotificationManager
Convenient and comprehensive api for push notification,provide 6 stems and 20 branchs' function,offer examples written by Objective-C and Swift respectively
Install / Use
/learn @apdevzhang/PushNotificationManagerREADME
PushNotificationManager
Convenient and comprehensive api for push notification ,provide 6 stems and 20 branchs' function,offer examples written by Objective-C and Swift respectively<br/>
Index
- Asset<br/> project assets for local push notification,include picture、image and video
- PushNotificationManager<br/> push notification API
- PushNotificationManagerExample-ObjC<br/> the example for API usage written by Objective-C
- PushNotificationManagerExample-Swift<br/> the example for API usage written by Swift
- screenshot<br/> project operation screenshot
Catalog
<a name="API"></a>
API
<pre> PushNotificationManager.h PushNotificationManager.m </pre><a name="Brief"></a>
Brief
- push notification style of normal
- normal with default alert sound
- provide a customized alert sound
- push notification style of graphics
- normal with default alert sound
- provide a customized alert sound
- provide a graphics download from internet
- provide a graphics download from internet and a customized alert sound
- push notification style of video
- normal with default alert sound
- provide a customized alert sound
- provide a video download from internet
- provide a video download from internet and a customized alert sound
- push notification style of timing(Chinses Time)
- normal with default alert sound(weekday、hour、minute、second)
- provide a customized alert sound(weekday、hour、minute、second)
- push notification style of timing like
2017-10-1(year、month、day、hour、minute、second) - push notification style of timing like
2017-10-1(year、month、day、hour、minute、second) and a customized alert sound - push notification style of timing,the fire date is included in a dictionary
- push notification style of timing,the fire date is included in a dictionary,provide a customized alert sound
- push notification style of interactive(the max action is four)
- normal with default alert sound
- provide a customized alert sound
- push notification style of location
- normal with default alert sound
- provide a customized alert sound
<a name="Preview"></a>
Preview
mainpage screenshot1 | mainpage screenshot2 | mainpage screenshot3 | mainpage screenshot4
-----|-----|-----|-----
|
|
| 
push notification style of normal | push notification style of graphics | push notification style of video
-----|-----|-----
|
| 
interactive setp1 | interactive setp2 | interactive setp3
-----|-----|-----
|
| 
interactive gif | video gif
-----|-----
| 
<a name="License"></a>
License
PushNotificationManageruse [MIT license][1]
<a name="Installation"></a>
Installation with cocoapods
<pre> pod 'PushNotificationManager' </pre>
<a name="Examples"></a>
Examples
make sure you install thePushNotificationManagerwith cocoapods or import the files ofPushNotificationManagerbefore use
Apply the push notification permission
- Objective-C
if (@available(iOS 10.0, *)) {
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
UNAuthorizationOptions types=UNAuthorizationOptionBadge|UNAuthorizationOptionAlert|UNAuthorizationOptionSound;
[center requestAuthorizationWithOptions:types completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (granted) {
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
//
}];
} else {
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@""} completionHandler:^(BOOL success) { }];
}
}];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wdeprecated-declarations"
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeSound | UIUserNotificationTypeBadge categories:nil]];
}
#pragma clang diagnostic pop
- Swift
if #available(iOS 10.0, *) {
let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.delegate = self
let types = UNAuthorizationOptions([.alert,.badge,.sound])
notificationCenter.requestAuthorization(options: types, completionHandler: { (flag, error) in
if flag {
print("注册成功")
} else {
print("注册失败:\(error.debugDescription)")
}
})
} else {
let setting = UIUserNotificationSettings.init(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(setting)
}
UIApplication.shared.registerForRemoteNotifications()
push notification style of normal
- function
-(void)normalPushNotificationWithTitle:(NSString *)title
subTitle:(NSString *)subTitle
body:(NSString *)body
identifier:(NSString *)identifier
timeInterval:(NSInteger)timeInterval
repeat:(BOOL)repeat;
- Objective-C usage
[[PushNotificationManager sharedInstance]normalPushNotificationWithTitle:@"John Winston Lennon" subTitle:@"《Imagine》" body:@"You may say that I'm a dreamer, but I'm not the only one" identifier:@"1-1" timeInterval:3 repeat:NO]; //`repeat` if you pick the repeat property 'YES',you require to set the timeInterval value >= 60second ->是否重复,若要重复->时间间隔应>=60s
- Swift usage
PushNotificationManager().normalPushNotification(withTitle: "John Winston Lennon", subTitle: "《Imagine》", body: "You may say that I'm a dreamer, but I'm not the only one", identifier: "1-1", timeInterval: 3, repeat: false)
push notification style of normal,provide a customized alert sound,e.g. @"intro.mp3"
- function
-(void)normalPushNotificationWithTitle:(NSString *)title
subTitle:(NSString *)subTitle
body:(NSString *)body
identifier:(NSString *)identifier
soundName:(NSString *)soundName
timeInterval:(NSInteger)timeInterval
repeat:(BOOL)repeat;
- Objective-C usage
[[PushNotificationManager sharedInstance]normalPushNotificationWithTitle:@"John Winston Lennon" subTitle:@"《Imagine》" body:@"You may say that I'm a dreamer, but I'm not the only one" identifier:@"1-2" soundName:@"tmp.mp3" timeInterval:3 repeat:NO];
- Swift usage
PushNotificationManager().normalPushNotification(withTitle: "John Winston Lennon", subTitle: "《Imagine》", body: "You may say that I'm a dreamer, but I'm not the only one", identifier: "1-2", soundName: "tmp.mp3", timeInterval: 3, repeat: false)
push notification style of graphics,include the format of png、jpg、gif and other graphics formats
- function
-(void)graphicsPushNotificationWithTitle:(NSString *)title
subTitle:(NSString *)subTitle
body:(NSString *)body
identifier:(NSString *)identifier
fileName:(NSString *)fileName
timeInterval:(NSInteger)timeInterval
repeat:(BOOL)repeat;
- Objective-C usage
[[PushNotificationManager sharedInstance]graphicsPushNotificationWithTitle:@"John Winston Lennon" subTitle:@"《Imagine》" body:@"You may say that I'm a dreamer, but I'm not the only one" identifier:@"2-1" fileName:@"Graphics.jpg" timeInterval:3 repeat:NO];
- Swift usage
PushNotificationManager().graphicsPushNotification(withTitle: "John Winston Lennon", subTitle: "《Imagine》", body: "You may say that I'm a dreamer, but I'm not the only one", identifier: "2-1", fileName: "Graphics.jpg", timeInterval: 3, repeat: false)
push notification style of graphics,provide a customized alert sound,e.g. @"intro.mp3"
- function
-(void)graphicsPushNotificationWithTitle:(NSString *)title
subT
