In this collation of some of the ideas of the predecessors, according to their understanding of the problem and similar aspects of the comparison did this note, this article is not explained in detail, just according to their own problems to solve a problem, I hope to have some help.
1. The difference between Devicetoken and Uuid,udid
Devicetoken:
A token that identifies the device to APS. The token is a opaque data type because that's the form the provider needs to submit to the APS servers when it sen DS a notification to a device. The APS servers require a binary format for performance reasons.
Note The device token is different from the uniqueidentifier property of Uidevice because, for security and privacy R Easons, it must when the device is wiped.
Tokens must change when the device is erased.
uuid:universally unique IDentifiers, translated is "global Unique identifier."
A UUID is a string that identifies a storage device in your system and is designed to help the user uniquely determine all the storage devices in the system, regardless of their type. It can identify DVD drives, USB storage devices, and hard drive devices in your system. A typical UUID looks like this:
BF930680-9994-442C-8A6C-FB4FD0707EB2 (128bit 32 bit 16 binary)
Why use UUID:
> 1. It's really the only sign
The UUID provides a unique identification string for the storage device in the system, regardless of the type of device. If you add a new storage device, such as a hard disk, to your system, it can cause problems, such as failure to find a device when you start it, and no problem with a UUID.
> 2. Device name is not always the same
Automatically assigned device names are not always consistent, and they depend on the order in which the kernel loads the modules at startup. If you start the system when you plug in a USB drive and then unplug it the next time you start it, you may have inconsistent device name assignments.
Using the UUID is also good for mounting mobile devices-for example, I have a 24-in-one reader that supports a wide variety of cards, while using a UUID can always be used to mount the same card in the same place.
Many of the key features in > 3.ubuntu are now dependent on UUID
Some of the principles before the procedure:
Device token, which is not a unique identifier of the system, requires that you initiate an Apple server request when the app starts, register your device and app, and get this device token.
What's the use of device token? If the app requires push notification to the phone, it needs to have a server-side (provider), but it does not send the message directly to the phone, but must be handed over to Apple's server, which is Apple push notification Server (APNs). Apple server through this token, know the app to send the message is to which mobile device, and forward the message to the phone, the phone and then notify the application.
Udid:unique device Identifier, a unique identifier for an Apple iOS device, consists of 40-character letters and numbers (jailbroken devices can change the device's UDID by some tools). Mobile networks can use UDID to identify mobile devices, but since iOS5.0 (August 2011), Apple has announced that it will no longer support the use of the uniqueidentifier method to obtain the udid,ios5 of the device below. On March 21, 2013 Apple has informed developers that, from May 1, 2013 onwards, the program to access Udids will no longer be approved, and the alternative is that developers should use the vendor or advertising identifiers described in IOS6. So Udid is absolutely useless.
For more information see: http://zengrong.net/post/2152.htm
2. Various stages of push:
> App Registration Push service notifications (to iOS)
> iOS system requests a device token from the APNS server
The > app receives device token
> App sends tokens to your own server
> Send a push notification to APNS when something triggers your push service.
> APNs Send this push notification to your app
After the certificate is equipped:
> Add the following code to the Didfinishlaunchingwithoptions method in the appdelegate of the project:
#define IOS8 [[Uidevice Currentdevice] Systemversion].doublevalue >= 8.0
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {
Override point for customization after application launch.
To differentiate whether it is iOS8
#ifdef IOS8
Uiusernotificationsettings *notisettings = [uiusernotificationsettings settingsfortypes: ( Uiusernotificationtypealert | Uiusernotificationtypebadge | Uiusernotificationtypesound) Categories:nil];
[Application registerusernotificationsettings:notisettings];
#else
[Application registerforremotenotificationtypes: (uiremotenotificationtypealert| uiremotenotificationtypebadge| Uiremotenotificationtypesound)];
#endif
> Add receive Information section
-(void) Application: (UIApplication *) application Didregisterforremotenotificationswithdevicetoken: (NSData *) Devicetoken
{
NSLog (@ "Devicetoken");
}
-(void) Application: (UIApplication *) application didreceiveremotenotification: (nsdictionary *) userInfo
{
Did receive the push message
NSLog (@ "%@", userInfo);
}
3. Local notification: Be sure to enter the background to see the effect
Uilocalnotification *notification = [[Uilocalnotification alloc] init];
if (notification! = nil) {
NSDate *now = [NSDate new];
Notification.firedate = [now addtimeinterval:10.0];
Notification.timezone = [Nstimezone defaulttimezone];
Notification.alertbody = @ "going to dinner";
Application.applicationiconbadgenumber = 10; Display to icon in the top right corner
[Application schedulelocalnotification:notification];
}
Uilocalnotification instances, there are three main types of properties
* Scheduled time, period, to specify the date and time when the iOS system sends notifications;
* Notification type, notification types, including warning message, action button title, app icon on badge (digital marker) and playback sound;
* Custom data, local notifications can contain a dictionary type of local data
4. Remote notification (all notifications on 3rd are remote notifications)
Preparation of equipment
The first thing to know is that the push notification can only be run on a real machine, cannot be used on the emulator, and if it is running on the emulator, there will be an error similar to the following when registering:
Error in registration. Error:error domain=nscocoaerrordomain code=3010 "Remote notifications is not supported in the simulator" userinfo=0x5d24 9d0 {nslocalizeddescription=remote Notifications is not supported in the simulator}
Real machines also need to be aware that if there is no jailbreak, no problem. Jailbreak words, such as through Blacksnow, because without itunes, unable to generate a valid device certificate (Devices certificate), so the registration will not be successful.
For specific reference: http://blog.csdn.net/kiki1985/article/details/8809220
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
IOS message push and local notifications, principle analysis