惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 阿木申

spring JPA 动态查询 [vb]sendkeys [vb]键盘精灵 - 阿木申 - 博客园 javascript 画带箭头的线段 关于input type='file'的内容的一种解决方法,模拟键盘 - 阿木申 - 博客园 防止IE缓存,就相当于IE选择每次打开就检查 - 阿木申 - 博客园 [dojo] 解决传中文的乱码问题 - 阿木申 - 博客园 [dojo] dojo.xhrGet和.net整合使用 [dojo]好用的页面对话框dijit.Dialog [dojo]日期选择:dijit.form.DateTextbox [dojo]功能强大的文本框:dijit.form.ValidationTextbox - 阿木申 - 博客园 dojo0.9 dojo.data研究笔记 [dojo] dojo 0.9 的使用心得 [原创]jBPM 子流程的使用 [原创]jBPM动态生成任务实例,会签或者分派任务时特别有用 [dojo转]动态生成widget [原创]jBpm中泳道使用心得 [原创]jBPM中的Expression和script [原创]JBPM中的基本操作代码
iOS收到Push后播放声音和震动
阿木申 · 2014-03-25 · via 博客园 - 阿木申

一、APNS

1.注册


[cpp]
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert]; 

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
2.服务器推送(JAVA)


[java]
PushNotificationPayload payLoad =  PushNotificationPayload.fromJSON(message);  
              
        payLoad.addAlert("iphone推送测试 www.baidu.com"); // 消息内容   
              
        payLoad.addBadge(count); // iphone应用图标上小红圈上的数值   
              
        payLoad.addSound("default"); // 铃音 默认  

PushNotificationPayload payLoad =  PushNotificationPayload.fromJSON(message);
            
        payLoad.addAlert("iphone推送测试 www.baidu.com"); // 消息内容
            
        payLoad.addBadge(count); // iphone应用图标上小红圈上的数值
            
        payLoad.addSound("default"); // 铃音 默认
二、程序内

1.震动

添加系统框架:


[cpp]
#import <AudioToolbox/AudioToolbox.h> 

#import <AudioToolbox/AudioToolbox.h>
调用震动代码:


[cpp]
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); 

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
2.消息声音

2.1 系统声音


[cpp]
AudioServicesPlaySystemSound(1007); 

AudioServicesPlaySystemSound(1007);其中1007是系统声音的编号,其他的可用编号:

iphone系统声效

2.2 用户音效


[cpp]
//音效文件路径  
    NSString *path = [[NSBundle mainBundle] pathForResource:@"message" ofType:@"wav"]; 
    //组装并播放音效  
    SystemSoundID soundID; 
    NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO]; 
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID); 
    AudioServicesPlaySystemSound(soundID); 
        //声音停止  
        AudioServicesDisposeSystemSoundID(soundID); 

//音效文件路径
 NSString *path = [[NSBundle mainBundle] pathForResource:@"message" ofType:@"wav"];
 //组装并播放音效
 SystemSoundID soundID;
 NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
 AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
 AudioServicesPlaySystemSound(soundID);
        //声音停止
        AudioServicesDisposeSystemSoundID(soundID);