【转载自友盟消息推送iOS文档】在appDelegate中注册推送
1.2 基本功能集成指南
提示
请先在友盟的消息推送管理后台中创建App,获得AppKey和AppSecret
导入SDK
- 下载 UMessage_Sdk_All_x.x.x.zip并解压缩
- 导入插件
所需SDK文件夹:
UMessage_Sdk_x.x.x
请在你的工程目录结构中,右键选择Add->Existing Files…,选择这个文件夹。或者将这个文件夹拖入XCode工程目录结构中,在弹出的界面中勾选Copy items into destination group's folder(if needed), 并确保Add To Targets勾选相应的target。配置(可选)
- SDK采用ARC管理内存,非ARC项目也是默认支持,如遇问题,请联系我们
- 如果您使用了
-all_load,可能需要添加libz的库:
TARGETS-->Build Phases-->Link Binary With Libraries-->+-->libz.dylib
说明
SDK支持iOS 4.3+添加代码
定义宏
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define iOS8 SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")
打开
*AppDelegate.m,依次按照以下步骤集成:didFinishLaunchingWithOptions中的设置:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//set AppKey and AppSecret
[UMessage startWithAppkey:@"your appkey" launchOptions:launchOptions];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= _IPHONE80_
if(iOS8)
{
//register remoteNotification types (iOS 8.0及其以上版本)
UIMutableUserNotificationAction *action1 = [[UIMutableUserNotificationAction alloc] init];
action1.identifier = @"action1_identifier";
action1.title=@"Accept";
action1.activationMode = UIUserNotificationActivationModeForeground;//当点击的时候启动程序
UIMutableUserNotificationAction *action2 = [[UIMutableUserNotificationAction alloc] init]; //第二按钮
action2.identifier = @"action2_identifier";
action2.title=@"Reject";
action2.activationMode = UIUserNotificationActivationModeBackground;//当点击的时候不启动程序,在后台处理
action2.authenticationRequired = YES;//需要解锁才能处理,如果action.activationMode = UIUserNotificationActivationModeForeground;则这个属性被忽略;
action2.destructive = YES;
UIMutableUserNotificationCategory *categorys = [[UIMutableUserNotificationCategory alloc] init];
categorys.identifier = @"category1";//这组动作的唯一标示
[categorys setActions:@[action1,action2] forContext:(UIUserNotificationActionContextDefault)];
UIUserNotificationSettings *userSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert
categories:[NSSet setWithObject:categorys]];
[UMessage registerRemoteNotificationAndUserNotificationSettings:userSettings];
} else{
//register remoteNotification types (iOS 8.0以下)
[UMessage registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound
|UIRemoteNotificationTypeAlert];
}
#else
//register remoteNotification types (iOS 8.0以下)
[UMessage registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound
|UIRemoteNotificationTypeAlert];
#endif
//for log
[UMessage setLogEnabled:YES];
return YES;
}
didRegisterForRemoteNotificationsWithDeviceToken中设置
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[UMessage registerDeviceToken:deviceToken];
}
didReceiveRemoteNotification中设置
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
[UMessage didReceiveRemoteNotification:userInfo];
}
说明
如需关闭推送,请使用[UMessage unregisterForRemoteNotifications]
至此,消息推送基本功能的集成已经完成。
【转载自友盟消息推送iOS文档】在appDelegate中注册推送的更多相关文章
- 友盟消息推送api、python sdk问题、测试demo代码
一,友盟消息推送python服务端sdk地址和文档地址 1.sdk地址:http://dev.umeng.com/system/resources/W1siZiIsIjIwMTYvMDgvMTkvMT ...
- 为友盟消息推送开发的PHP SDK(composer版):可以按省发Android push
一直以来APP希望按省市县推送Android push,只能自己分析用户经纬度,打tag发送. 现在终于有服务商提供了. 友盟消息推送 可以“按省推送”,很方便. 我为友盟做了PHP SDK(comp ...
- .NET手记-友盟消息推送服务器端加密算法的实现
最近为App开发消息推送功能,这里我们采用了友盟的消息推送服务,但其后台简陋,可定制化程度低,所以决定接入服务器端API,在自己的服务器上部署一套推送服务. 其中涉及到很多问题,首先要解决的就是与友盟 ...
- umeng友盟消息推送功能集成
umeng友盟消息推送功能集成(本人使用的是eclipse开发) 1.首先请自行观看友盟消息推送集成的API文档. 观看地址如下: http://dev.umeng.com/push/android/ ...
- 友盟消息推送UPush
第一步:把下载的SDK里面的PushSDK当做Module导入自己的项目 第二步:在自己项目的build.gradle里面一定要配置applicationId defaultConfig { appl ...
- 友盟消息push功能
友盟地址:https://i.umeng.com/user/products 一.android 1.产品->U-App/U-push->立即使用->管理->左侧-集成测试-& ...
- iOS文档预览功能教程
本文转载至 http://blog.csdn.net/devday/article/details/6580444 文档iosuinavigationcontrollerextensionmic ...
- RTX消息提醒工具设计文档
为什么要做 项目上线后,系统依然由各业务模块负责人自己维护.而后台运行的各种业务服务结果,不能及时反馈到业务负责人.而等到客户反馈时则会太被动.为了能及时发现并解决项目问题,设计了该工具. 可利用资源 ...
- 友盟消息推送和更新XML配置
<receiver android:name="com.umeng.message.NotificationProxyBroadcastReceiver" android:e ...
随机推荐
- [android]android开发中的运行错误之:adb.exe
调试的时候出现一下错误: The connection to adb is down, and a servera error has occured.You must restart adb and ...
- right way check file open and end
check if a state is ok while(cin >> word) // ok: read successful condition states are constant ...
- 从外部导入jar包的三种方式
我们在用Eclipse开发程序的时候,经常要用到第三方jar包.引入jar包不是一个小问题,由于jar包位置不清楚,而浪费时间.下面配图说明3种Eclipse引入jar包的方式. 1.最常用的普通操作 ...
- 使用DatagramSocket与DatagramPacket传输数据
参考传智播客毕向东JAVA视频. 注: DatagramSocket发送的每个包都需要指定地址,而Socket则是在首次创建时指定地址,以后所有数据的发送都通过此socket. A socket is ...
- 读取xml文件转成List<T>对象的两种方法(附源码)
读取xml文件转成List<T>对象的两种方法(附源码) 读取xml文件,是项目中经常要用到的,所以就总结一下,最近项目中用到的读取xml文件并且转成List<T>对象的方法, ...
- Oracle中index by binary_integer的作用
如语句:type numbers is table of number index by binary_integer;其作用是,加了”index by binary_integer ”后,num ...
- 解决Webservice内存溢出-用XmlWriter
XmlWriter 表示一个编写器,该编写器提供一种快速.非缓存和只进的方式来生成包含 XML 数据的流或文件.这个就可以不占用内存,将数据放入磁盘中.也就不会出现内存溢出 public class ...
- 关于css浮动的一些总结
首先给浮动一个定义吧 浮动可以理解为让某个div元素脱离标准流,漂浮在标准流之上,和标准流不是一个层次. 从测试中来看 元素之间的浮动关系是根据上一个元素来判断的如果上一个元素是浮动的它会跟在浮动元素 ...
- org.quartz.impl.jdbcjobstore.LockException
说明:在使用Tomcat6.0.32+Spring3.05+Quartz1.8.6+Mysql5.5.9 此项目在我本机上没有问题,当我把mysql 脚本导入到服务器上,将数据源配置修改为服务器对应的 ...
- scheme 模拟queue
[code 1] shows a implementation of queue. The function enqueue! returns a queue in that the obj is a ...