Introduction to the IOS notification mechanism

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.