使用UILocalNotification是不是需要用安卓真机测试才能测试的

&&&&//发送通知
&&&&UILocalNotification&*notification=[[UILocalNotification&alloc]&init];&&&
&&&&if&(notification!=nil)&{&
&&&&&&&&NSDate&*now=[NSDate&new];&
&&&&&&&&notification.fireDate=[now&dateByAddingTimeInterval:10];//10秒后通知
&&&&&&&&notification.repeatInterval=0;//循环次数,kCFCalendarUnitWeekday一周一次
&&&&&&&&notification.timeZone=[NSTimeZone&defaultTimeZone];
&&&&&&&&notification.applicationIconBadgeNumber=1;&//应用的红色数字&
&&&&&&&&notification.soundName=&UILocalNotificationDefaultSoundN//声音,可以换成alarm.soundName&=&@"myMusic.caf"&
&&&&&&&&//去掉下面2行就不会弹出提示框
&&&&&&&&&notification.alertBody=@"通知内容";//提示信息&弹出提示框
&&&&&&&&&notification.alertAction&=&@"打开";&&//提示框按钮&
&&&&&&&&//notification.hasAction&=&NO;&//是否显示额外的按钮,为no时alertAction消失
&&&&&&&//&NSDictionary&*infoDict&=&[NSDictionary&dictionaryWithObject:@"someValue"&forKey:@"someKey"];
&&&&&&&&//notification.userInfo&=&infoD&//添加额外的信息
&&&&&&&&[[UIApplication&sharedApplication]&scheduleLocalNotification:notification];&&&&&&
&&&&[notification&release];取消通知-&(BOOL)application:(UIApplication&*)application&didFinishLaunchingWithOptions:(NSDictionary&*)launchOptions&{&&&&&&&&&&&&//&Override&point&for&customization&after&application&launch.&&&&application.applicationIconBadgeNumber&=&0;&&&&//&Add&the&view&controller's&view&to&the&window&and&display.&&&&[window&addSubview:viewController.view];&&&&[window&makeKeyAndVisible];&&&&return&YES;}-&(void)application:(UIApplication&*)application&didReceiveLocalNotification:(UILocalNotification&*)notification&{&&&&//点击提示框的打开&&&&application.applicationIconBadgeNumber&=&0;}-&(void)applicationDidBecomeActive:(UIApplication&*)application&{&&&&//当程序还在后天运行&&&&application.applicationIconBadgeNumber&=&0;}
阅读(...) 评论()uilocalnotification怎么设置后台提醒_百度知道
uilocalnotification怎么设置后台提醒
提问者采纳
如果不设置的话:localNotification];提醒&quot:@&quot,在iOS下应用分为两种不同的Notification种类,如sound1、soundName和userInfo将使UILocalNotification更完整、 alertA
NSLog(@&quot,第一个方式可以直接取消一个指定的Notification,UILocalNotification的属性涵盖了所有处理Notification需要的内容、repeatInterval和repeatCalendar是用于UILocalNotification的调度,将不会重复激发:localNotification],声音名称要加上扩展名、 soundName和userInfo,例如闹钟类的应用,如果不设置的话,系统处理UILocalNotification提醒是需要的内容。soundName是另一个UILocalNotification用来提醒用户的手段,让同样的任务可以非常简单得被处理,等待应用加载时显示的图片;Close&quot。而且因为系统统一对Notification的管理,本地和远程,在Notification被激发之后将播放这段声音来提醒用户有Notification需要处理(有声音设置时:这个Application delegate方法中处理,而且可以非常好的节省资源、alertBody,这个将替代应用原本设置的加载图片、hasAction和alertLaunchImage是当应用不在运行时,默认值为YES。timeZone是UILocalNotification激发时间是否根据时区改变而改变,NSWeekCalendarUnit、applicationIconBadgeNumber:
[[UIApplication sharedApplication]
scheduleLocalNotification.alertBody
delegate。本地的Notification由iOS下NotificationManager统一管理,可以在 -(BOOL)application。 repeatInterval是UILocalNotification被重复激发之间的时间差,第二个方式将会把该应用已登记的Notification一起取消
[[UIApplication sharedApplication] cancelLocalNotification.applicationState,如果 alertBody未设置的话,系统会在指定的时间激发将本地NOK&
if (state == UIApplicationStateActive) {
UIAlertView *alert = [[UIAlertView alloc] initWithT/一般需要应用程序后台运行时才会显示提示,只需处理对象携带的userInfo来处理响应的动作;%@,不过时间差是完全根据日历单位(NSCalendarUnit)、repeatCalendar,则可以通过将下面函数加到appDelegate中实现。登记UILocalNotification在设置完UILocalNotification对象之后:didReceiveLocalN&#47。UILocalNotification的其他部分applicationIconBadgeNumber,应用只需设计好处理Notification的方法就完成了整个Notification流程了。登记UILocalNotification * localNotification的方式为;在有些时候,可以很好的帮助开发者管理一些指定时间需要发生的事件:@&quot,这样让用户直接了解到应用需要处理的 Notification,可以通过覆盖在Application Delegate中的方法-(void)application。本地Notification所使用的对象是UILocalNotification,只需要将封装好的本地Notification对象加入到系统Notification管理机制队列中、alertAction:localNotification],前台运行时一般不显示提示、timeZone,state)。可以通过以下方式来加载为最近未处理的Notification,如果设置为nil的话。userInfo是Notification用来传递数据的NSDictionary:self
cancelButtonT
[alert show];处理UILocalNotification在提醒框动作按钮被点击后;
}}总结本地Notification的机制在应用开发中非常有效:(UILocalNotification *)notification{
UIApplicationState state = application、repeatInterval。 repeatCalendar是UILocalNotification重复激发所使用的日历单位需要参考的日历,系统默认的日历将被作为参考日历:
[[UIApplication sharedApplication] presentLocalNotificationNow,提醒信息中的动作按钮将显示为“View”相对文字形式,Notification被激发时将不现实提醒:(UIApplication *)application didReceiveLocalNotification。UILocalNotification的调度其中fireDate。hasAction是一个控制是否在提醒框中显示动作按钮的布尔值,应用开始运行时:@&quot:didFinishLaunchingWithOptions。applicationIconBadgeNumber是显示在应用图标右上角的数字,如果不设soundName的话,应用需要在系统Notification处理队列中登记已设置完的UILocalNotification对象,alertAction的内容将作为提醒中动作按钮上的文字:- (void)
[alert release],nil],%d&quot、hasAction,也可以将soundName设为UILocalNotificationDefaultSoundName来使用系统默认提醒声音.mp3):来处理 Notification。UILocalNotification的提醒内容alertBody。如果想要当应用程序前台应行时也显示提示、timeZone:UIApplicationLaunchOptionsLocalNotificationKey]。alertLaunchImage是在用户点击提醒框中动作按钮(“View”)时、alertLaunchImage,应用可以以下的方式直接触发已设好的Notification,而不是某一个确切时间被激发。UILocalNotification的属性有fireDate,那么UILocalNotification将在一段时候后被激发;
message。取消UILocalNotification可以使用以下两个方式来取消一个已经登记的N;如果应用正在运行时iOS下的Notification的使用 Notification是智能手机应用编程中非常常用的一种传递信息的机制;
[[UIApplication sharedApplication] cancelAllLocalNotification],应用可能需要直接激发一个Notification而不是等一段时间在激发。fireDate是UILocalNotification的激发的确切时间,不用消耗资源来不停地检查信息状态(Pooling)。alertBody是一串现实提醒内容的字符串(NSString),例如每周激发的单位。alertAction也是一串字符(NSString):,Notification被激发是将不会有声音播放,除去应用特制的声音以外:
UILocalNotification * localNotif=[launchOptions objectForKey。作为方法的第二个参数为UILocalNotification对象,
otherButtonTitles,如果未设置的话
其他类似问题
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁如何关闭UILocalNotification时的振动_百度知道
如何关闭UILocalNotification时的振动
提问者采纳
系统决定震动还是不震动,设置中的振动既然已经是开启的了,本地通知这个是系统的机制这个应该实现不了,那应该就是震动的了
其他类似问题
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁使用UILocalNotification是不是需要用真机才能测试的_百度知道
使用UILocalNotification是不是需要用真机才能测试的
我有更好的答案
按默认排序
本地的Notification由iOS下NotificationManager统一管理;如果应用正在运行时,而且可以非常好的节省资源。applicationIconBadgeNumber是显示在应用图标右上角的数字、applicationIconBadgeNumber.mp3),只需处理对象携带的userInfo来处理响应的动作、timeZone,不用消耗资源来不停地检查信息状态(Pooling);&#47,前台运行时一般不显示提示,那么UILocalNotification将在一段时候后被激发:
[[UIApplication sharedApplication]
scheduleLocalNotification、 alertAction,Notification被激发时将不现实提醒,应用可以以下的方式直接触发已设好的Notification,不过时间差是完全根据日历单位(NSCalendarUnit);一般需要应用程序后台运行时才会显示提示。登记UILocalNotification在设置完UILocalNotification对象之后,本地和远程.applicationState。timeZone是UILocalNotification激发时间是否根据时区改变而改变;
NSLog(@&quot。UILocalNotification的属性有fireDate:
UILocalNotification * localNotif=[launchOptions objectForK
}}总结本地Notification的机制在应用开发中非常有效,第一个方式可以直接取消一个指定的Notification。hasAction是一个控制是否在提醒框中显示动作按钮的布尔值。取消UILocalNotification可以使用以下两个方式来取消一个已经登记的Notification,如果不设置的话。作为方法的第二个参数为UILocalNotification对象:(UIApplication *)application didReceiveLocalNotification。UILocalNotification的调度其中fireDate:这个Application delegate方法中处理,例如闹钟类的应用,在iOS下应用分为两种不同的Notification种类;处理UILocalNotification在提醒框动作按钮被点击后:
[[UIApplication sharedApplication] presentLocalNotificationNClose&quot,除去应用特制的声音以外,默认值为YES:UIApplicationLaunchOptionsLocalNotificationKey]、alertAction,如果不设soundName的话、soundName和userInfo将使UILocalNotification更完整。alertAction也是一串字符(NSString)。登记UILocalNotification * localNotification的方式为,如果 alertBody未设置的话,如果设置为nil的话,应用开始运行时,只需要将封装好的本地Notification对象加入到系统Notification管理机制队列中。 repeatInterval是UILocalNotification被重复激发之间的时间差,state):didFinishLaunchingWithOptions,Notification被激发是将不会有声音播放,在Notification被激发之后将播放这段声音来提醒用户有Notification需要处理(有声音设置时,可以在 -(BOOL)application,系统会在指定的时间激发将本地Notification、 soundName和userInfo。alertBody是一串现实提醒内容的字符串(NSString)、hasAction,如果不设置的话:localNotification],让同样的任务可以非常简单得被处理:notification,这个将替代应用原本设置的加载图片,NSWeekCalendarUnit、repeatCalendar,应用只需设计好处理Notification的方法就完成了整个Notification流程了,alertAction的内容将作为提醒中动作按钮上的文字。UILocalNotification的其他部分applicationIconBadgeNumber。本地Notification所使用的对象是UILocalNotification:localNotification]、repeatInterval:- (void)application,也可以将soundName设为UILocalNotificationDefaultSoundName来使用系统默认提醒声音。而且因为系统统一对Notification的管理,可以通过覆盖在Application Delegate中的方法-(void)application:来处理 Notification。UILocalNotification的提醒内容alertBody。soundName是另一个UILocalNotification用来提醒用户的手段,这样让用户直接了解到应用需要处理的 Notification,等待应用加载时显示的图片,系统处理UILocalNotification提醒是需要的内容;
[alert show],例如每周激发的单位;
message.alertBody
[[UIApplication sharedApplication] cancelAllLocalNotification]:@&quot,UILocalNotification的属性涵盖了所有处理Notification需要的内容,如sound1、alertBody。如果想要当应用程序前台应行时也显示提示,nil]。fireDate是UILocalNotification的激发的确切时间,如果未设置的话,系统默认的日历将被作为参考日历、alertLaunchImage,%d&quot,应用可能需要直接激发一个Notification而不是等一段时间在激发、timeZone,OK&quot。alertLaunchImage是在用户点击提醒框中动作按钮(“View”)时,可以很好的帮助开发者管理一些指定时间需要发生的事件、repeatInterval和repeatCalendar是用于UILocalNotification的调度;
if (state == UIApplicationStateActive) {
UIAlertView *alert = [[UIAlertView alloc] initWithT%@:@&quot:localNotification],将不会重复激发,而不是某一个确切时间被激发。 repeatCalendar是UILocalNotification重复激发所使用的日历单位需要参考的日历;
otherButtonTitles,第二个方式将会把该应用已登记的Notification一起取消
[[UIApplication sharedApplication] cancelLocalNotification、hasAction和alertLaunchImage是当应用不在运行时;提醒&在有些时候,则可以通过将下面函数加到appDelegate中实现,提醒信息中的动作按钮将显示为“View”相对文字形式。可以通过以下方式来加载为最近未处理的Notification,声音名称要加上扩展名。userInfo是Notification用来传递数据的NSDictionary:self
cancelButtonTitle,应用需要在系统Notification处理队列中登记已设置完的UILocalNotification对象:@&quot:didReceiveLocalNotification:(UILocalNotification *)notification{
UIApplicationState state =;/;
[alert release]iOS下的Notification的使用 Notification是智能手机应用编程中非常常用的一种传递信息的机制
其他类似问题
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁决定要用第三方移动推送了,哪位可以推荐一下比如腾讯信鸽、小米之类的各有什么特点?能有测评数据最好了。
谢药~话说最近自己的应用也正在使用第三方的推送服务,说白了,我们这些刚起步的做的应用,选第三方推送的要求也挺简单:免费,稳定,好用。后来选来选去,还是用的腾讯信鸽。-------------------------------------------------介绍的分割线---------------------------------------------------帮人帮到底,我这里简单的介绍一下腾讯信鸽,因为我们是做的IOS应用,所以这里以IOS版为例。简单介绍下测试环境:MAC
OS (10.9.2) +XCode (5.1.1)iPhone4
iOS6.1.3总体腾讯信鸽推送开发流程登陆QQ—&注册程序名—&选择应用—&上传证书—&集成开发-—&集成开发—&测试应用—&发布应用第一步,客户端集成1.
登陆以及使用信鸽地址: ,使用QQ登陆,登陆后,填写应用的名称以及资料,填写完成后,提交2.
申请IOS推送证书,并生成pem文件(熟悉推送证书创建的可跳过这步)另外,官方也提供了详细的教程 :(1)登陆 iOS Dev Center 选择进入iOS Provisioning Portal;(2)在 Identifiers中,点击App IDs进入App ID列表,创建 App ID,为 App 开启 Push Notification 功能;(3)指定具体的 Bundle ID,创建完成;(4)在Certificates,中新建一个证书,选择Apple Push Notification service SSL;(5)点击 Continue 后选择证书对应的App ID(即刚才创建的App ID),继续会需要上传一个本地CSR文件,然后就会生成一个 APNs Push
Certificate;(6)下载并双击打开证书,证书打开时会启动“钥匙串访问”工具。在“钥匙串访问”中你的证书会显示在“我的证书”中,注意选择“My Certificates”
和"login";(7)在“钥匙串访问”中,选择刚刚加进来的证书,选择右键菜单中的“导出“...””。
将文件保存为MyApnsCert.p12。保存p12文件时,可以为其设置密码,也可以让密码为空。(8)把上一步生成的p12证书文件放到桌面,转换成pem证书文件。在终端里运行一下命令转换:cd desktopopenssl pkcs12 –in MyApnsCert.p12 –out
MyApnsCert.pem –nodes输入提示密码,就是p12的导出密码,桌面就会生成一个pem证书文件3.
配置新应用点击应用配置对创建的应用进行配置将配置的证书进行上传,每个应用会对应唯一的ACCESS ID ACCESS KEY
下载iOS SDK
选择iOS SDK 下载后,会得到一个压缩包,我们需要的SDK以及DEMO,都在这个包文件夹里面2.
集成开发1、 下载信鸽Pro SDK压缩包到本地并解压;2、 创建或打开Xcode iOS工程;3、 将SDK目录下的所有文件添加到Xcode工程;4、 添加对以下libraries的引用。核心实现文件为XGPushPro.h和XGPushPro.m。这两个文件整合了XG和MTA来增强信鸽。接口调用的地方请参考AppDelegate.m文件。API接口类名
说明XGPushPro
信鸽Pro版本的Push服务,推送效果推送被打开效果统计如果需要统计由信鸽推送的点击或者打开,需要开发者在didReceiveRemoteNotification(如果没有则按照下面的示例手动添加)中调用handleReceiveNotification
, 然后在didFinishLaunchingWithOptions中调用handleLaunching。函数原型:+(void)handleReceiveNotificationPro:(NSDictionary
*)userI//app在前台或者后台运行时+(void)handleLaunchingPro:(NSDictionary
*)launchO//app不在运行时,点击推送激活时参数说明:事件本身默认的参数名返回值:无示例:-
(void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo{
[XGPushPro handleReceiveNotificationPro:userInfo];} - (BOOL)application:(UIApplication
*)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[XGPushPro
handleLaunchingPro: launchOptions];}三测试DEMOAPPDelegate.h#import &UIKit/UIKit.h&@interface AppDelegate : UIResponder &UIApplicationDelegate&@property (strong, nonatomic) UIWindow *@endAPPDelegate.m#import "AppDelegate.h"#import "XGPush.h"#import "XGPushPro.h"#import "MTA.h"#import "MTAConfig.h"@implementation
AppDelegate- (void)registerNofitication {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions{
[self registerNofitication];
[[MTAConfig getInstance] setDebugEnable:TRUE]; //是否查看MTA调试信息
[MTA startWithAppkey:@"IG4BJ2YGZ14F"];
//初始化app
[XGPush startApp: appKey:@"IMJ34Y25JN4I"];
//推送反馈(app不在前台运行时,点击推送激活时)
[XGPushPro handleLaunchingPro:launchOptions];
return YES;}-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification{
//notification是发送推送时传入的字典信息
[XGPush localNotificationAtFrontEnd:notification userInfoKey:@"clockID" userInfoValue:@"myid"];
//删除推送列表中的这一条
[XGPush delLocalNotification:notification];
delLocationNotification:@"clockID" userInfoValue:@"myid"];
//清空推送列表
//[XGPush clearLocalNotifications];}- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {#ifdef DEBUG
//NSLog(@"development mode");#else
//NSLog(@"distribution mode");#endif
//注册设备
//[XGPush setAccount:@"123456"];
NSString * deviceTokenStr = [XGPush registerDevice: deviceToken];
//打印获取的deviceToken的字符串
NSLog(@"deviceTokenStr is
%@",deviceTokenStr);}- (void)application:(UIApplication *)app
didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSString *str = [NSString stringWithFormat: @"Error: %@",err];
NSLog(@"%@",str);}- (void)application:(UIApplication*)application
didReceiveRemoteNotification:(NSDictionary*)userInfo{
//推送反馈(app在前台运行时) 如果是纯净版信鸽
handleReceiveNotification:userInfo];
//如果是信鸽Pro,上报信息给MTA
[XGPushPro handleReceiveNotificationPro:userInfo];}- (void)applicationWillResignActive:(UIApplication *)application{
// 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
// 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.}- (void)applicationDidEnterBackground:(UIApplication *)application{
// 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.
// If your application supports background
execution, this method is called instead of applicationWillTerminate: when the
user quits.}- (void)applicationWillEnterForeground:(UIApplication *)application{
// Called as part of the transition from
the background t here you can undo many of the changes
made on entering the background.}- (void)applicationDidBecomeActive:(UIApplication *)application{
// 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.}- (void)applicationWillTerminate:(UIApplication *)application{
// Called when the application is about to
terminate. Save data if appropriate. See also applicationDidEnterBackground:.}@end希望能够帮助到大家}

我要回帖

更多关于 苹果真机测试 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信