Basic knowledge of ios10 push (required)

preface

At 1:00 a.m. Beijing time on September 14, apple officially launched the official version of IOS 10. Let's give you a detailed introduction to the basic knowledge of IOS 10 push. After reading the simple introduction, you can simply adapt, and then through the content of the intermediate article, I believe it will be very helpful for you to learn and understand. I won't say much below. Let's have a look.

1、 Simple introduction

I won't talk about the relatively simple problems of pushing certificates and environment here. What I'm talking about here refers to the adaptation of the original project.

1. First, we need to turn on the following switch. All push platforms, whether aurora or something, must be turned on if they want to receive push~

After that, the system will generate a file we have not seen before, as shown in the figure:

Possible problems: some friends have reported before that changing the development environment from development to production will cause errors here, as shown in the figure:

If you click fix issue, you will be surprised to find that APS environment has changed from production to development.

Solution: my suggestion is not to make any changes.

After my test, there is no such thing in the IPA package generated after packaging Of the entitlements file. After testing, I found that I can normally receive push messages. The test method is as follows. You can also test it.

Test method: install IPA files after packaging, and then use Aurora push to select the production environment and push.

After the above operations, you will be surprised to find that the push has been adapted, and the IOS 10 system can receive notifications normally.

2、 Intermediate article

Here I will tell you about the push of ios10, how to register, through what agent, which methods can be used and which methods can not be used.

1. System built-in method

Whether you use the push of the third-party platform or the push of the system, you should first understand the system's own method and how to realize the remote notification.

Step 1: import #import < usernotifications / usernotifications h>

And abide by the protocol of < unusernotificationcenterdelegate >, in appdelegate M.

It should be noted here that we'd better write it in this form

Step 2: we need to register the notification in (bool) application: (uiapplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchoptions. The code is as follows:

The method of obtaining device token remains unchanged.

For the update of ios10 system, apple gave us two proxy methods to handle notification receiving and click events. These two methods are in the protocol of < unusernotificationcenterdelegate >, which you can check. In addition, apple combines local notification with remote notification. The class that distinguishes local notification from remote notification is unpushnotificationtrigger In class h, the type of unpushnotificationtrigger is newly added. Through it, we can get some notification trigger conditions. When using this class, we should not directly use this class, but use its subclasses.

Let me be brief

1. Type of notification pushed remotely by unpushnotificationtrigger

2. Untimeintervalnotificationtrigger: push notifications repeatedly or not after a certain period of time. We can set timeinterval and repeats.

3. Unalendornotificationtrigger (local notification) push notifications repeatedly or not after a certain date. For example, if you push a notification at 8 o'clock every day, as long as the datecomponents are 8. If you want to push this notification at 8 o'clock every day, as long as the repeats are yes.

4. Unloocationnotificationtrigger (local notification) is a kind of notification of geographical location. When users enter or leave a geographical area, the identifier must be unique in clregion. Because if the same identifier identifies unnotificationrequests in different areas, it will lead to uncertain behavior.

The code for receiving the notification is as follows:

The following code is the notified click event:

In the click event, if we do not write the completionhandler () method, we may report an error. I hope you will pay attention~

Finally, we want you to add some methods in the old version to facilitate you to expand the notification of ios10 without affecting the original logic.

2. Aurora push (need to download the latest version)

If some platforms of three parties are used, it will be easier to push.

1. The registration notice code is as follows:

After registration, we need to add two new methods after Aurora push update. These two methods are in the < jpushregisterdelegate > proxy method.

When using, you only need to add the processing method of Aurora in the above code, as shown in the following figure:

Through the above article, I believe you can have a preliminary understanding of the push of the new version and how to deal with it~

summary

The above is all about the basic knowledge of ios10 push. Don't you know that everyone has learned it? I hope this article can be helpful to IOS developers. If you have any questions, you can leave a message.

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
分享
二维码
< <上一篇
下一篇>>