ios pull代码不提示成功_GitHub - huipengo/WBNotification: 一行代码注册推送通知,适配iOS8+,包含 device token 转字符串方法;判断APP是否允...

WBNotification

68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f2545352542442541442545382542452538392f57424e6f74696669636174696f6e2e7376673f7374796c653d666c6174

68747470733a2f2f696d672e736869656c64732e696f2f636f636f61706f64732f762f57424e6f74696669636174696f6e2e7376673f7374796c653d666c6174

68747470733a2f2f696d672e736869656c64732e696f2f636f636f61706f64732f6c2f57424e6f74696669636174696f6e2e7376673f7374796c653d666c6174

68747470733a2f2f696d672e736869656c64732e696f2f636f636f61706f64732f702f57424e6f74696669636174696f6e2e7376673f7374796c653d666c6174

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];

}

};

});

}

Push 功能自测:

1、先打开 Keychain Access,点击 证书,再选中相应证书(小三角不要展开) -> 导出证书 -> 选择 个人信息交换格式选项(.p12) 保存;

2、在终端 cd *.p12 所在目录文件,然后输入以下命令生成 *.pem 文件;

openssl pkcs12 -in ck.p12 -out ck.pem -nodes

3、拷贝 ck.pem 文件到 Demo 中的 Push_Beta 文件夹,并在 Push_Beta.php 做相应修改(替换生成*.pem文件时的密码,device token,推送内容等);

4、在终端执行命令:cd 到 Push_Beta 文件夹,再执行 php Push_Beta.php 即可验证生成的 push 证书是否有效 以及 项目中推送功能 是否正常;

推荐一个好用的工具 Easy APNs Provider 直接测试 push ,可到 AppStore 进行下载

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

License

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值