deviceToken :
A token that identifies the device to APS. The token is an opaque data type because that is the form that the provider needs to submit to the APS servers when it sends a notification to a device. The APS servers require
a binary format for performance reasons.
Note that the device token is different from the uniqueIdentifier property of UIDevice because, for security and privacy reasons, it must change when the device is wiped.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UILocalNotification的实例,主要有三类属性
* scheduled time, 时间周期,用来指定iOS系统发送通知的日期和时间;
* notification type,通知类型,包括警告信息、动作按钮的标题、应用图标上的badge(数字标记)和播放的声音;
* 自定义数据,本地通知可以包含一个dictionary类型的本地数据
4. 远程通知(第3点上的所有通知皆为远程通知)
设备的准备
首先要知道,push notification 只能在真机上运行的,无法在模拟器上使用,如果在模拟器上运行,在注册时会有类似如下错误:
Error in registration. Error: Error Domain=NSCocoaErrorDomain Code=3010 "remote notifications are not supported in the simulator" UserInfo=0x5d249d0 {NSLocalizedDescription=remote notifications are not supported in the simulator}
真机也需要注意,如果没有越狱,没有问题。越狱的话,比如通过blacksnOw,因为没有经过iTunes,无法生成有效的设备证书(device certificate),因此注册的时候不会成功。