Latest 0.1.0
Homepage https://github.com/huipengo/WBNotification
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

WBNotification is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'WBNotification'

使用简单说明

注册推送通知方法:

1、WBAppDelegate.m 里面导入头文件

#import "WBNotificationTool.h"

2、- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{} 方法里面添加注册推送通知代码:

wb_configureNotification(launchOptions);

3、在 WBAppDelegate.m 里面添加如下代码:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { wb_saveNotificationDeviceToken(deviceToken); }

4、WBNotificationTool.m类里面做如下处理即可做到点击通知栏一条消息,消失一条消息,而不是全部消失:

+ (void)load {
    [[NSNotificationCenter.defaultCenter rac_addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil]
 subscribeNext:^(NSNotification *notification) {
     [WBNotification.notification didLaunchingWithOptions:nil];
     wb_execLocalNofitication(0);
 }];

    [[NSNotificationCenter.defaultCenter rac_addObserverForName:UIApplicationWillTerminateNotification object:nil]
 subscribeNext:^(NSNotification *notification) {
     /// 杀死应用发送延迟1秒,否则红点不消失
     wb_execLocalNofitication(1);
 }];
}

5、打开系统设置推送界面方法:

void wb_enterAppSystemSetting() {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
dispatch_async(dispatch_get_main_queue(), ^{
    BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:url];
    if (@available(iOS 10.0, *)) {
        NSDictionary *options = @{};
        if (canOpen) {
            [[UIApplication sharedApplication] openURL:url options:options completionHandler:^(BOOL success) {

            }];
        }
    }
    else {
        if (canOpen) {
            canOpen = [[UIApplication sharedApplication] openURL:url];
        }
    };
});
}



  • 具体使用可查看Demo,若喜欢请Star,谢谢~~~

Author

彭辉, [email protected]

License

WBNotification is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "WBNotification",
    "version": "0.1.0",
    "summary": "u5c01u88c5u7cfbu7edfu63a8u9001u901au77e5uff1bdevice token u8f6cu5b57u7b26u4e32uff1bu63a8u9001u6d88u606fu70b9u51fbu4e00u6761u6d88u5931u4e00u6761uff0cu800cu4e0du662fu70b9u51fbu5168u90e8u6d88u5931uff1bu70b9u51fbu6253u5f00u7cfbu7edfu8bbeu7f6eu63a8u9001u901au77e5u754cu9762uff1b u65b9u4fbfu7b80u6d01.",
    "description": "u4e00u884cu4ee3u7801u6ce8u518cu63a8u9001u901au77e5uff0cu9002u914diOS8+uff0cu5305u542b device token u8f6cu5b57u7b26u4e32u65b9u6cd5uff1bu5224u65adAPPu662fu5426u5141u8bb8u63a8u9001u65b9u6cd5uff1bu63a8u9001u6d88u606fu70b9u4e00u6761u6d88u5931u4e00u6761uff0cu8df3u8f6cu7cfbu7edfu8bbeu7f6eu63a8u9001u901au77e5u754cu9762uff1b",
    "homepage": "https://github.com/huipengo/WBNotification",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "u5f6du8f89": "[email protected]"
    },
    "source": {
        "git": "https://github.com/huipengo/WBNotification.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "Pod/Classes/*.{h,m}"
}

Pin It on Pinterest

Share This