Notification (messaging) mechanism for iOS
Two types of notifications are available in iOS
1. Local Notifications
A local notification is an instance of Uilocalnotification that contains the following three important attributes:
Scheduling time: To use local notifications, you must specify the date and time that the notification is triggered, and you can set the recurrence interval for the notification, such as repeating by week or repeating by month
Notification type: Used to specify the hint text information, the caption of the action button, the number on the application icon, and the sound to play
Custom data: Local notifications can also contain a dictionary of custom data
To set the properties of a notification:
Alertbody: Information Content
Alertaction: Message title
Applicationiconbadgenumber: The number on the icon
Soundname: The sound to play
Uilocalnotificationdefaultsoundname: Using the default system sound
You can also attach a data dictionary to a local notification by using the UserInfo property
iOS allowed maximum number of local notifications allowed: 64
2. Remote Notification
Apple provides a bunch of servers, each iOS device and these servers maintain a long connection, iOS version update prompts, phone clock calibration and other operations are implemented through this connection
The Message Push service, abbreviated as APNS (Apple Push Notification service), is a service in this long connection and must be brokered through APNs if you want to send a message to the user
Message push does not support mass, only one hair
Message packets typically consist of two parts: the ID of the user's phone (32 bytes) + The message body (<=256bytes), the message body is a JSON string, and the transfer process uses SSL encryption
Marking the user's phone ID is also called device token, each phone is different, Device token is very important!
Device tokens for each machine are different, but not hardware encoded (UDID)
Device tokens may change if the operating system is reinstalled
Device token is generated by ASPN when a user's phone initiates a request
Introduction to the IOS notification mechanism