Uilocalnotification of local notifications pushed by IOS

Absrtact: notification is a very common mechanism for transmitting information in Smartphone Application Programming, and it can save resources very well, Don't consume resources to constantly check the status of information (pooling), there are two different types of notifications in IOS applications, local and remote. Local notifications are uniformly managed by the notificationmanager in IOS. You only need to add the encapsulated local notification object to the system notification management mechanism queue. The system will trigger the local notification at the specified time, and the application only needs to design and process the notificatio The method of N completes the whole notification process. Notification is a very common mechanism for transmitting information in Smartphone Application Programming, and it can save resources very well, Don't consume resources to constantly check the status of information (pooling), there are two different types of notifications in IOS applications, local and remote. Local notifications are uniformly managed by the notificationmanager in IOS. You only need to add the encapsulated local notification object to the system notification management mechanism queue. The system will trigger the local notification at the specified time, and the application only needs to design and process the notificatio The method of N completes the whole notification process.

The object used by local notification is uilocalnotification. The attribute of uilocalnotification covers all the contents required to process notification. The attributes of uilocalnotification include firedate, timezone, repeatinterval, repeatcalendar, alertbody, alertaction, hasaction, alertlaunchimage, applicationiconbadgenumber, soundname and userinfo.

Scheduling of uilocalnotification

Firedate, timezone, repeatinterval and repeatcalendar are the schedulers for uilocalnotification. Firedate is the exact time when the uilocalnotification was fired. Timezone is whether the uilocalnotification firing time changes according to the time zone. If it is set to nil, the uilocalnotification will be fired after a period of time rather than at an exact time. Repeatinterval is the time difference between uilocalnotification being repeatedly fired, However, the time difference is completely based on the calendar unit (nscalendarunit), such as the unit fired every week, nsweekcalendarunit. If it is not set, it will not be fired repeatedly. Repeatcalendar is the calendar that needs to be referenced by the calendar unit used for uilocalnotification repeated firing. If it is not set, the default calendar will be used as the reference calendar.

Reminder content of uilocalnotification

Alertbody, alertaction, hasaction and alertlaunchimage are processed by the system when the application is not running

1. Add a local push

2. A local push message was received while the program was running

3. Cancel a local push

4. There are two ways to cancel the local notice of registration: one is to cancel the specified notice, and the other is to cancel all registration notices:

5. Four notification types of ios5

5.1. Banner

Banner notification is a new feature in IOS 5. It is a banner displayed at the top of the screen and will disappear automatically after a few seconds. A banner notification will display a small icon of the program (29 on the low screen) × 29 icon, high score screen display 58 × 58), the name of the program and the content of the notification. Small icons can help users see which application is reminding them at a glance.

5.2. Reminder (ALERT)

The reminder notification will not disappear automatically and needs user interaction to close. The designer needs to design the specific content of the notice, and sometimes the action button design title. The background style of the whole reminder notice, including the style of the buttons inside, is immutable, so designers and developers should not be creative here. Because of Android's openness, we can use our own designed controls, while IOS may do so to maintain the consistency of UI style.

5.3. Marker (badge)

Mark notification is a red oval mark displayed in the upper right corner of the program icon. The number displayed in it indicates the number of notifications that need to be processed by the user. Similarly, the color, shape and size of the mark cannot be changed. The number of updated applications in the app store and the number of unread messages received in mail are marked to inform users.

5.4. Sound

Voice prompt is also a notification method of IOS. It supports customization and can be used with the previous three notification types.

6. Local and push notifications

IOS applications use local notifications or push notifications to remind users:

6.1. Local notification

The local notification of the application is generated and published by the user's IOS device, whether the application is running in the foreground or not. Like a calendar application or a to-do list application, you can send a local notification to remind users that a meeting is about to start.

6.2. Push notification

The push notification of the application is published as follows: the remote server (provider) of the application sends a notification to Apple's push notification service (APNs), and then Apple's notification server pushes the notification to all IOS devices installed with the application.

If you want to use push notifications, you must first register the types of notifications you want to use in Apple's push notification service. For example, the following code means that both tag and sound notifications are registered at the same time:

How to use various notifications

Applications that use local notifications can use banners, reminders, tags, and sounds, but applications that use push notifications need to register the type of notification they want to use first.

The following points should be noted when using Notifications:

1. Ensure that the contents of the mark are up-to-date

2. Do not send multiple notices for the same event

3. The notification content does not include the name of the application

For marked notifications, when all matters are resolved, the mark will disappear automatically.

In the banners and reminders, as well as in the notification center at the top, the IOS system will automatically display the name of the application in the message, so there is no need to include the name of the app when designing the content of the notification.

When designing the contents of the notice, you should also pay attention to:

1. Focus on the expression of information rather than the user's actions. Avoid prompting users to click which button or how to open the app

2. Short, preferably no more than two lines. Long messages are difficult to read quickly, and there must be scroll bars

3. Use sentence style capitalization (capitalize the first letter of the first word) and appropriate punctuation, and generally use a period at the end

About "reminder"

A reminder may contain one or two buttons. For a reminder with two buttons, you need to put the button to close the reminder on the left and the action button on the right.

Click the button on the left to close the reminder, and click the button on the right to close the reminder and open the application.

If there is only one button, this button should be an OK button.

Clicking this OK button will only close the reminder, not open the application.

For the reminder notice, you should pay attention to the following when designing the title of the action button:

1. The title can accurately describe the action of opening the application. For example, click the play button to open the game, and users can play it immediately

2. Use Title Style capitalization (the first letter of each word is capitalized)

3. Short enough

When a new reminder is received in the lock screen state, the title of the action button will be displayed in the "slide to view" message, the word "view" will be replaced, and all letters will be converted to lowercase.

About "sound"

For voice prompt, when users are not using the mobile phone, the voice can attract their attention, which can avoid users from missing important information.

We can use the built-in sound of the system or customize the sound. If you use a custom sound, make sure it is short enough and carefully crafted.

About "notice bar"

As long as the screen is not locked, you can slide down from the top of the screen to open the notification center.

If it is in a game, such as fruit ninja, in order to prevent the finger from accidentally sliding out of the screen and opening the notification center, ios5 improves the difficulty of opening the notification Center: first pull down a pull-down bar with anti-skid lines from the top of the screen, and then drag it down again to open the notification center. Otherwise, the pull-down bar will be automatically retracted after a few seconds. The design of the anti slip drop-down bar here can help new users quickly establish the mental model of the drop-down opening notification center.

OS5 organizes the notifications in the drop-down notification bar, and the notifications of the same app are combined according to time sequence. To delete the notification message of an app, first click the "X" button on the right, the "X" button will change to "clear", and the user can click clear again to remove all notifications under the app. The two-step operation reduces the probability of false deletion, and its interactive form is much more friendly than the common modal window of pop-up secondary confirmation.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>