IOs消息推送

app推送服务开通到使用 S.content=这是通知的内容,你好,这是内容。只是你如果自定义成自己的域名后,会变成你的域名。怕 dcloud 域名长不好记,可以绑定你自己备案过的域名。通过https://${云函数Url化域名}/${path}直接访问函数,其中${path}是配置的函数触发路径或其子路径。选择什么云,和你在 dcloud 后台创建关联的云一样就可以了。简单吧,自定义的域名短呀短,好记呀好记。页面,点击页面底下的。 阅读详情

好久没有写过博客啦,今天就由本菜鸟给大家做一个简单的IOSApp消息推送教程吧!一切从0开始,包括XCode6, IOS8, 以及苹果开发者中心最新如何注册应用,申请证书以及下载配置概要文件,相信很多刚开始接触iOS的人会很想了解一下。(ps:网上看了一下虽然有很多讲述推送的好教程,我也是看着一步步学会的,但是这些教程的时间都是去年或者更早时期的,对引导新手来说不是很合适)

第一部分

首先第一步当然是介绍一下苹果的推送机制(APNS)咯(ps:其实每一篇教程都有),先来看一张苹果官方对其推送做出解释的概要图。

Provider是给你手机应用发出推送消息的服务器,而APNS(Apple Push Notification Service)则是苹果消息推送服务器。你本地的服务器当需要给应用推送一条消息的时候,先要将消息发出到苹果推送服务器,然后再由苹果推送服务器将消息发到安装了该应用的手机。

接下来再看一张解释图:


根据上图的逻辑我来给大家解释一下:

1.你的IOS应用需要去注册APNS消息推送功能。

2.当苹果APNS推送服收到来自你应用的注册消息就会返回一串device token给你(很重要)

3.将应用收到的device Token传给你本地的Push服务器。

4.当你需要为应用推送消息的时候,你本地的推送服务器会将消息,以及Device Token打包发送到苹果的APNS服

5.APNS再将消息推送给目的iphone


第二部分

1.从证书颁发机构颁发证书

打开你mac的钥匙串访问: 然后点击钥匙串访问

随后它会弹出一个窗口 用户电子邮件信息

就填写你苹果开发者账号的名称即可(应该是一个邮件名称),点击保存到磁盘的选项,点击继续,显示如下



点击存储,文件名为:CertificateSigningRequest.certSigningRequest 随后将他放在一个文件夹中我们取名push吧!


第三部分


访问苹果开发者网址:https://developer.apple.com/

选中MemberCenter选项,进入登陆页面,用你的苹果开发者账号登陆,过一会网页就会自动跳转到下图。

点击红色所选部分

内容进行下一步的操作。


选择Certificates选项,设置证书,如图所示先解释一下

 

Development选项的作用顾名思义就是用来作为开发使用的证书,Production选项则

是用来发布产品使用的,名称很陌生是不是,之前的开发者网页是没有这一选项的,可能是苹果把他修改了,用这个名称更加能让人

理解吧(字面上解释就是产品么)。两个选项生成证书的步骤是一样的,现在我们使用开发者的选项进行证书的制作,步骤如下:

选择Development选项


点击上面的加号选项,


选择APNS选项(开发么当然是在沙盒环境下了,模拟真实情况),然后Continue


这个AppID我们在下一部分讲如何生成,现在我用的是已经生成好的一个应用ID,继续Continue


这边就要选择在钥匙串访问环节下载下来的CertificateSigningRequest.certSigningRequest文件了,选择并生成


点击下载,得到aps_development .cer,保存到push文件中去。


第四部分

新建一个AppID,选择网页上的AppIDs,然后点击右上角的 “加号”


App的取名只要按照苹果要求的就可以了


然后BundleID是比较重要的,在提交审核以及测试(苹果的TestFlight)和付费环节都需要用到,也只需按照苹果要求来写就好了。


接下来就是对你的应用需要使用苹果的哪些服务进行选择就行了,例如广告,游戏中心,推送,付费等等情况。


最后选择“Submit”选项,在下一个界面中选择“done”选项,这样我们设置AppID的步骤我们就完成了。


第五部分:生成Provisioning Profiles

这个配置概要文件分为两种,一种是为开发使用的,还有一种则是为发布到appStore上面。


创建发布版的ProvisioningProfile与开发版的流程相同,点击Development然后点击右上角的加号

会进入选择何种配置概要文件的界面


我们现在时测试,所以选择“IOS App Development”的选项,在下面的Distribution发布选项中有两个选择,“App Store”以及“Ad hoc”,你可以根据下面的描述

选择你发布所需的选项。点击Continue进入下一步。


选择你上一步创建的AppID,点击Continue 进行下一步


选择你的开发者账号,Continue进行下一步


在这一步上选择你的设备(你只有在这一步上勾选了你的设备,你才能在设备上用这个签名进行调试)。关于如何将你的设备号添加进去也是非常

简单的,选择左侧的"Devices",然后点击右上角的加号,在随后出来的页面上添加你设备的UUID(在XCode中可以查看到)以及name( 可以随便取,自己看的懂就行)

然后Register一下,照着流程走到最后一步就完成了。

好咋们继续回到上面的Provisioning Profile配置环节,当你选好了你的设备后点击“Continue”进入下一页,


输入一个文件名(最好是起的能看懂是干嘛的,当然也可以随便起),点击“Generate”进入下一个页面,在这个页面中就会有一个下载按钮让你下载这个文件,

我们把它下载下来放在Push文件夹中。


第六部分

好了,前期的准备工作都已经做完了,现在让我们开始推送吧!(吼吼)

首先双击我们生成的 “aps_development .cer” 文件,进入钥匙串访问,找到我们的专用秘钥(根据在第二部分中从证书机构颁发证书操作中填写的常用名)


我在第二部分填写的是“silicon”,由于换了一台mac之前安装的没有了,之前没有截图,所以随便找了个图给大家看一下,凭大家的聪明才智应该不难理解吧。

然后右击导出,会弹出如下所示的图。



将他存储到push文件夹中,命名为“push.p12”,在这一步中导出会让你输入密码并验证,你可以自定义一个密码,例如abc123。


现在push文件夹中应该有几个文件“aps_development .cer” ,"push.p12",“CertificateSigningRequest.certSigningRequest”以及刚才下下来的配置概要文件。


接下来我们打开终端将他们生成.pem文件

1.把aps_development .cer文件生成.pcm文件,cd到push文件夹下


2.把push.p12文件生成为.pem文件


上边输入的密码则是你导出证书所设的密码,即abc123.接着还会让你输入.pem文件的密码,还是使用abc123好了,防止混淆。

这样我们在push文件夹中就又得到了两个文件,PushChatCert.pem和PushChatKey.pem。


3.把PushChatCert.pem和PushChatKey.pem合并为一个pem文件,


在push文件夹中又多了一个ck.pem文件,以上我们把需要使用的文件都准备好了


接下来就要测试一下啦,是不是很激动~

为了测试证书工作的状况,我们可以使用“telnet gateway.sandbox.push.apple.com 2195”来检测一下,如果显示


则表示成功了。


然后,我们使用我们生成的证书和私钥来设置一个安全的链接去链接苹果服务器

在终端输入如下命令:openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert PushChatCert.pem -key PushChatKey.pem

需要输入密码(abc123 我们刚才所设置的)。

然后他会返回一系列的数据,这里我就粘贴一部分啦:

CONNECTED(00000003)

depth=1 /C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C

verify error:num=20:unable to get local issuer certificate

verify return:0

---

Certificate chain

。。。。。(省略)

。。。。。(省略)

。。。。。(省略)

    Start Time: 1416389389

    Timeout   : 300 (sec)

    Verify return code: 0 (ok)

---

测试就到这里啦。。。


第七部分

1.建立推送项目

[objc]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. //  
  2. //  AppDelegate.m  
  3. //  TestPushNotifiy  
  4. //  
  5. //  Created by silicon on 14-10-30.  
  6. //  Copyright (c) 2014年 silicon. All rights reserved.  
  7. //  
  8.   
  9. #import "AppDelegate.h"  
  10.   
  11. @implementation AppDelegate  
  12. @synthesize mainView = _mainView;  
  13.   
  14. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions  
  15. {  
  16.     if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])  
  17.     {  
  18.         //IOS8  
  19.         //创建UIUserNotificationSettings,并设置消息的显示类类型  
  20.         UIUserNotificationSettings *notiSettings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIRemoteNotificationTypeSound) categories:nil];  
  21.           
  22.         [application registerUserNotificationSettings:notiSettings];  
  23.           
  24.     } else{ // ios7  
  25.         [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge                                       |UIRemoteNotificationTypeSound                                      |UIRemoteNotificationTypeAlert)];  
  26.     }  
  27.       
  28.     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];  
  29.     // Override point for customization after application launch.  
  30.     self.window.backgroundColor = [UIColor whiteColor];  
  31.     [self.window makeKeyAndVisible];  
  32.       
  33.     self.mainView = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];  
  34.     self.window.rootViewController = self.mainView;  
  35.     return YES;  
  36. }  
  37.   
  38. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)pToken{  
  39.     NSLog(@"---Token--%@", pToken);  
  40. }  
  41.   
  42. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{  
  43.       
  44.     NSLog(@"userInfo == %@",userInfo);  
  45.     NSString *message = [[userInfo objectForKey:@"aps"]objectForKey:@"alert"];  
  46.       
  47.     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:message delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil nil];  
  48.       
  49.     [alert show];  
  50. }  
  51.   
  52. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{  
  53.   
  54.     NSLog(@"Regist fail%@",error);  
  55. }  
  56.   
  57. - (void)applicationWillResignActive:(UIApplication *)application  
  58. {  
  59.     // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.  
  60.     // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.  
  61. }  
  62.   
  63. - (void)applicationDidEnterBackground:(UIApplication *)application  
  64. {  
  65.     // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.   
  66.     // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.  
  67. }  
  68.   
  69. - (void)applicationWillEnterForeground:(UIApplication *)application  
  70. {  
  71.     // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.  
  72. }  
  73.   
  74. - (void)applicationDidBecomeActive:(UIApplication *)application  
  75. {  
  76.     // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.  
  77. }  
  78.   
  79. - (void)applicationWillTerminate:(UIApplication *)application  
  80. {  
  81.     // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.  
  82. }  
  83.   
  84. @end  

在appdelegate.m中加入以上代码,

[objc]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])  
  2.     {  
  3.         //IOS8  
  4.         //创建UIUserNotificationSettings,并设置消息的显示类类型  
  5.         UIUserNotificationSettings *notiSettings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIRemoteNotificationTypeSound) categories:nil];  
  6.           
  7.         [application registerUserNotificationSettings:notiSettings];  
  8.           
  9.     } else{ // ios7  
  10.         [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge                                       |UIRemoteNotificationTypeSound                                      |UIRemoteNotificationTypeAlert)];  
  11.     }  
由于ios8的推送跟ios7及以下的不一样,所以需要加判断来注册消息推送。

函数:

[objc]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)pToken{  
  2.     NSLog(@"---Token--%@", pToken);  
  3. }  
会接收来自苹果服务器给你返回的deviceToken,然后你需要将它添加到你本地的推送服务器上。(很重要,决定你的设备能不能接收到推送消息)。

[objc]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{  
  2.       
  3.     NSLog(@"userInfo == %@",userInfo);  
  4.     NSString *message = [[userInfo objectForKey:@"aps"]objectForKey:@"alert"];  
  5.       
  6.     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:message delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil nil];  
  7.       
  8.     [alert show];  
  9. }  

这个函数则是当设备接收到来自苹果推送服务器的消息时触发的,用来显示推送消息。

[objc]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{  
  2.   
  3.     NSLog(@"Regist fail%@",error);  
  4. }  
当注册失败时,触发此函数。


2.PHP服务端

将simplepush.php这个推送脚本也放在push文件夹中

[php]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <?php  
  2.   
  3. // ??????????deviceToken???????????????  
  4. $deviceToken = 'c95f661371b085e2517b4c12cc76293522775e5fd9bb1dea17dd80fe85583b41';  
  5.   
  6. // Put your private key's passphrase here:  
  7. $passphrase = 'abc123';  
  8.   
  9. // Put your alert message here:  
  10. $message = 'My first push test!';  
  11.   
  12. ////////////////////////////////////////////////////////////////////////////////  
  13.   
  14. $ctx = stream_context_create();  
  15. stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');  
  16. stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);  
  17.   
  18. // Open a connection to the APNS server  
  19. //??????????  
  20.  //$fp = stream_socket_client(?ssl://gateway.push.apple.com:2195?, $err, $errstr, 60, //STREAM_CLIENT_CONNECT, $ctx);  
  21. //?????????????appstore??????  
  22. $fp = stream_socket_client(  
  23. 'ssl://gateway.sandbox.push.apple.com:2195', $err,  
  24. $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);  
  25.   
  26. if (!$fp)  
  27. exit("Failed to connect: $err $errstr" . PHP_EOL);  
  28.   
  29. echo 'Connected to APNS' . PHP_EOL;  
  30.   
  31. // Create the payload body  
  32. $body['aps'] = array(  
  33. 'alert' => $message,  
  34. 'sound' => 'default'  
  35. );  
  36.   
  37. // Encode the payload as JSON  
  38. $payload = json_encode($body);  
  39.   
  40. // Build the binary notification  
  41. $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;  
  42.   
  43. // Send it to the server  
  44. $result = fwrite($fp, $msg, strlen($msg));  
  45.   
  46. if (!$result)  
  47. echo 'Message not delivered' . PHP_EOL;  
  48. else  
  49. echo 'Message successfully delivered' . PHP_EOL;  
  50.   
  51. // Close the connection to the server  
  52. fclose($fp);  
  53. ?>  
deviceToken填写你接收到的token,passPhrase则填写你的ck.pem设置的密码。

此刻就是见证奇迹的时候了

使用终端进入到push文件夹,在终端输入 php simplepush.php


若显示以上提示则表示推送成功了。

附上一张成功图。



推送就到这边吧!

感谢这篇博客的指导:http://blog.youkuaiyun.com/showhilllee/article/details/8631734


转自:http://blog.youkuaiyun.com/shenjie12345678/article/details/41120637

前端基于uniapp[uniPush]实现APP消息推送(安卓、IOS) 此文章都是基于uniapp中uniPush2实现的在线、离线推送。记录从0到1的实现和坑点 阅读详情

相关推荐

实现iOS消息推送

消息推送 iOS Push APNS Notification

701

iOS 推送证书 Apple Push Services:不受信任的解决办法

就是需要下载个中间证书,如果您计划使用 2022 年 1 月 27 日之后颁发的证书发送通知请求或通行证,则需要下载 Worldwide Developer Relations G4 子 CA!对于2021 1月28日之后生成的所有软件签名证书,由在Xcode中拥有个人帐户的开发人员和iOS大学开发人员计划成员提供的,也需要进行此更新。苹果开发者企业计划的成员需要在所有使用2020年9月1日之后生成的企业iOS分发证书进行代码签名的机器上安装续订的证书。下载后,导入一下即可解决不受信任的问题,亲测有效~

好好学习的博客 3108

App ios 消息推送

官方文档:开发者中心 首先看文档得有appkey,masterkey,url!!! 分享一个小技巧 友盟自带测试工具,可以先用测试工具调通,然后去看友盟生成的数据,跟你自己组装的数据的差别在哪里!有些数据不传就是收不到的!!!但是它的文档里面没写,好了,祝你成功! 代码: import org.apache.commons.codec.digest.DigestUtils; @Value("${appPush.url}") private String appPu..

forever_chm的博客 2659

IOS开发之实现App消息推送(最新)

久没有写过博客啦,今天就由本菜鸟给大家做一个简单的IOSApp消息推送教程吧!一切从0开始,包括XCode6, IOS8, 以及苹果开发者中心最新如何注册应用,申请证书以及下载配置概要文件,相信很多刚开始接触ios的人会很想了解一下。(ps:网上看了一下虽然有很多讲述推送的好教程,我也是看着一步步学会的,但是这些教程的时间都是去年或者更早时期的,对引导新手来说不是很合适) 第一部分 首先第一...

boweijie的专栏 558

使用海康机器人的SDK进行DWS开发时如何筛选不同类型的相机

使用MVIDCodeReader、MvCodeReaderSDK、MvVolMeasureSDK联合开发时,通常会做一些设备枚举列表,但是不同类型的设备需要枚举在不同的列表中,便于软件使用者配置参数,例如: 如何保证枚举出来的设备是可以选择的对应的设备。我们通常枚举出来的是这样的: 解决办法 在联合开发中,我们发现,只有MvVolMeasureSDK的枚举设备接口EnumStereoCamEx可以正确的只枚举出网络内的体积设备,其余的MVIDCodeReader、MvCodeReaderS

qq_29123967的博客 2732

用HFSS复现经典论文:从零搭建带孔缝屏蔽箱体模型(附完整建模步骤与避坑指南)

本文详细介绍了如何使用HFSS电磁仿真软件复现经典论文中的带孔缝屏蔽箱体模型,包括从零搭建模型、设置激励与边界条件、求解优化及结果验证的全过程。特别提供了建模中的布尔运算陷阱、激励设置技巧等实操难点的避坑指南,帮助工程师和学生深入理解电磁屏蔽效能研究。

weixin_30530339的博客 159

移动App的推送技术

前面的文章中介绍了通用的推送架构和技术,主要介绍了Web端,也讲了部分移动端App。这次则主要介绍移动端的技术原理,实现方法和编程实现。 一、技术原理 一旦服务器数据有更新或者服务器要下发通知给客户端只能等客户端连接的时候才能实现。这种方式使消息失去了实时性。 定义:推送功能最早是被用于Email中,用来提示我们新的信息。在移动互联网普及之后,手机终端成为了消息推送的主战场,例如生活服务类的...

answer3lin的博客 1万+

一文学会Cadence Sigrity PDN仿真——硬件新手小白都能看懂的保姆级教程

电源完整性的仿真,实际上是在仿真以及优化系统中的等效串联电阻。知道了仿真以及优化的目标之后,接下来就是要弄明白这个串联电阻从哪儿来以及怎么优化。整个系统中的串联电阻实际上由三部分组成:没有相位的阻抗,有相位的容抗和感抗,得益于相位,在某个特定的频点,容抗和感抗会大小相等,相位相反而相互抵消,这时候整个系统中就剩下了阻抗,所以整个系统的串联电阻达到了一个最低值,这种现象就是----谐振。当系统处于谐振点时候,整个系统会有一个最小的串联电阻,所以第一个优化电阻的手段就是让谐振来的更频繁一点。

学习帮的博客 2万+

iOS 的消息推送简析

iOS的消息推送简析 消息推送的目的是为了在应用切至后台或手机锁屏情况下,提醒用户当前时间APP内部发生了某事,吸引用户打开APP应用。 消息推送有三种提示类型: UIUserNotificationTypeBadge:应用的BadgeValue小红圈 UIUserNotificationTypeSound:声音或震动提示 UIUserNotificationTypeAlert:Alert展示Me...

冰是睡着的水的专栏 699

某头部能源集团“数据治理”到“数智应用”跃迁案例剖析

本次案例能源企业实现了从“数据可用”到“指标驱动”再到“智能决策”的全链条升级,标志着集团在数字化、智能化治理能力上的系统跃升,构建起面向未来的数智管理新范式。

a958014226的博客 1258

故障诊断知识库建设指南

从数据融合到知识图谱构建,从智能推理引擎开发到动态进化机制落地,故障诊断知识库的建设路径已形成 “数据 - 知识 - 智能” 的闭环体系。随着大模型技术的深度融入,知识库将实现从 “规则驱动” 到 “认知推理” 的跨越 —— 通过自然语言理解解析复杂故障描述、多模态分析融合图像与信号数据、预测性算法推演故障发展趋势,持续提升诊断的精准度与前瞻性。

极昆仑智慧 1232

iOS消息推送机制的实现

iOS消息推送的工作机制可以简单的用下图来概括:   Provider是指某个iPhone软件的Push服务器,APNS是Apple Push Notification Service的缩写,是苹果的服务器。   上图可以分为三个阶段: 第一阶段:应用程序把要发送的消息、目的iPhone的标识打包,发给APNS。  第二阶段:APNS在自身的已注册Push服务的iPhone列表

haoke 2万+

多后端系统统一聚合与智能分流:用 Multi Origin Composition 与 Routing 打造一套可扩展的 SAP Gateway 架构

本文针对企业级SAP集成场景,详细介绍了如何利用SAP Gateway的MOC(多源组合)和Routing功能实现多后端系统的智能路由与数据聚合。通过系统别名配置、用户角色绑定和主机名分流等机制,可实现按用户、按域名的精确路由。文章还提供了配置清单、性能优化建议和常见问题解决方案,帮助工程师落地多后端OData服务的最佳实践。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 186

iOS消息推送原理

它是苹果提供的全球推送服务,负责将消息从应用服务器传递到用户的设备。通过以上机制,iOS 消息推送实现了高效、安全的消息传递,同时兼顾用户体验与开发者灵活性。iOS 消息推送(Push Notification)的核心机制基于。用户授权后,系统会向 APNs 注册设备,并生成一个唯一的。应用首次启动时,需向用户请求推送权限(通过。:应用在前台时,推送不会自动展示,需通过。

zhangjikuan89的博客 1674

大数据在电力行业的应用案例解析-【电力技术】(九)大数据在电力储能运维中的深度应用(含故障预测代码)

大数据技术为电力储能运维提供了“精准化、智能化、高效化”的解决方案,破解了传统运维的核心痛点,实现了储能系统从“被动抢修”到“主动运维”的转型,为新型电力系统建设提供了重要支撑。当前,随着储能产业的快速发展,大数据与储能运维的融合将更加深入,未来将结合人工智能、物联网、区块链等技术,实现储能运维的全流程智能化——从设备故障的提前预警,到寿命的精准预测,再到运维策略的自动优化、调度协同的实时响应,进一步提升储能系统的安全性、经济性与可靠性。

getusushu的博客 88

数据挖掘实战-基于LSTM时间序列模型的香烟销售预测分析

本文介绍了基于LSTM时间序列模型的香烟销售预测分析实验。实验背景为烟草市场竞争激烈,企业需提高销售预测准确性以优化生产、库存和营销策略。LSTM模型因其处理长序列数据的能力被选为预测工具。实验步骤包括数据准备、特征工程、模型构建、训练与评估及结果分析。数据集来自某市门店的销售数据,技术工具为Python 3.9和Jupyter Notebook。实验过程涵盖数据导入、预处理、产品销售与区域销售分析、销售预测(包括销售额、销量、利润及海通店销售额预测)。

m0_64336780的博客 8952

iOS消息推送原理和实现总结

一、消息推送原理: 在实现消息推送之前先提及几个于推送相关概念,如下图:1、 Provider:就是为指定IOS设备应用程序提供Push的服务器,(如果IOS设备的应用程序是客户端的话,那么Provider可以理解为服务端[消息的发起者]);2、 APNS:Apple Push Notification Service[苹果消息推送服务器];3、 iPhone:用来接收APNS下发下...

weixin_30687051的博客 387

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

iOS开发之消息推送 —— 远程消息推送入门

每次看到iOS的远程消息推送,总是感觉很头大,即便后来项目都做完了,还是觉得摸不着远程推送的脉门,网上介绍的资料虽然多如牛毛,但不是写的太简单了,就是写的太详细了,不能一下抓住要点,今天终于能够抽出点时间,来扒一扒这其中究竟有怎样的奥秘。 根据苹果掌控一切的习惯,消息推送也当然不能例外,不论你在哪里推送,也不论你用什么方式推送,都必须首先把消息发给苹果的消息推送服务器APNs(),然后再由苹果消

雅香小筑 1万+

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

IOS 消息推送原理及实现总结

一、消息推送原理:   在实现消息推送之前先提及几个于推送相关概念,如下图1-1:    1-1 1、              Provider:就是为指定IOS设备应用程序提供Push的服务器,(如果IOS设备的应用程序是客户端的话,那么Provider可以理解为服务端[消息的发起者]); 2、              APNS:A

2904

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

IOS消息推送流程

IOS消息推送流程

西北风的专栏 1340

细说 iOS 消息推送

经常有同学问我们,iOS上推送究竟怎么做啊,为什么我的设备总收不到推送呢,这里跟大家集中讨论一下iOS上推送的实现细节。 APNS的推送机制 与Android上我们自己实现的推送服务不一样,Apple对设备的控制非常严格,消息推送的流程必须要经过APNs: 这里 Provider 是指某个应用的Developer,当然如果开发者使用AVOS Cloud的服务,把发送消息的请求委托给我们,那么这里的Provider就是AVOS Cloud的推送服务程序了。上图可以分为三步: 第一步:AVOS Cloud推送服

justbeme的专栏 632

iOS 实现消息推送及原理分析

摘抄:脚本之家一、消息推送原理在实现消息推送之前先提及几个于推送相关概念,如下图:1、简介 (1)、Provider:就是为指定IOS设备应用程序提供Push的服务器,(如果IOS设备的应用程序是客户端的话,那么Provider可以理解为服务端[消息的发起者]); (2)、APNS:Apple Push Notification Service[苹果消息推送服务器]; (3)、iPhone:用来接收

xiaoxiaobukuang的专栏 1573

iOS 消息推送原理及实现总结

iOS 消息推送原理及实现总结+1 一、消息推送原理: 在实现消息推送之前先提及几个于推送相关概念,如下图: 1、 Provider:就是为指定IOS设备应用程序提供Push的服务器,(如果IOS设备的应用程序是客户端的话,那么Provider可以理解为服务端[消息的发起者]); 2、 APNS:Apple Push Notification Servi

HorsonWu 1350

iOS消息推送

原文:http://blog.youkuaiyun.com/zhuqilin0/article/details/6527113 最近两天在研究ios的消息推送机制。研究这个东西,还是充满兴趣的。 Push的原理: Push 的工作机制可以简单的概括为下图 图中,Provider是指某个iPhone软件的Push服务器,这篇文章我将使用.net作为Provider。  APNS 是

iceleeb1234b的专栏 2975
上一篇: CocoaPods 安装和使用
下一篇: iOS [[UIApplication sharedApplication] openURL:]加载其它应用
攻城狮Corn
博客等级 码龄12年 2粉丝 53原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值