Two things to do with IOS 8: remote push and unwind Segue

Source: Internet
Author: User

Original: http://imtx.me/archives/1910.html


Yesterday I spat on Weibo: IOS 8/xcode 6 was the worst version of the developer ever. Received a lot of friends to express their sympathy.

The reason for this is that it's not about the features of iOS 8 itself, but the expansion mechanisms that iOS 8 opens and the various kits are great for developers.

I complained about Apple's recent poor control over software quality, and the last time I sent an iOS 8.0.1 that didn't work, iOS 8/xcode 6 itself was full of bugs. Xcode, as the IDE, often fails when submitting apps. For example, the other day I submitted the Manico 1.4.1 version, Xcode 6 also failed directly, and finally completed the submission with Xcode 5. This makes us very wohuo as developers.

In addition to this, Apple has become more and more aggressive on iOS, and in order to move forward with the new system features, Apple directly break the software's backwards compatible compatibility feature after the upgrade, and I was amazed. Let's talk about two recent encounters today.

In fact, I want to record these in Apple's WWDC should have mentioned, helpless video not all read, only in the time of the problem to solve.

changes in the remote push mechanism

If you are still using the Registerforremotenotificationtypes method to register the push function in the code, your app is compiled with the iOS 8 SDK, then your app will not be able to register the feature push under iOS 8 (under iOS 7 is available ). Instead of simply tagging the deprecated, Apple set the API to "not work" directly under IOS 8.

What API do you use to register the remote push feature under IOS 8? With the new api:registerforremotenotifications.

However, this API will only register a remote push with a silent feature, although the APP will receive push and process after it does not have any prompts on the user interface. So how do I complete remote push registration support under iOS 8 and under iOS 7? The following code allows push support to work correctly under iOS 7 and iOS 8, if it's iOS 8, and else there is iOS 7.

uiapplication *Application = [uiapplication sharedapplication];if ([Application Respondstoselector:@selector(isregisteredforremotenotifications)]) {    uiusernotificationsettings *Settings = [uiusernotificationsettings Settingsfortypes:(Uiremotenotificationtypebadge                                                                                         |Uiremotenotificationtypesound                                                                                         |Uiremotenotificationtypealert)                                                                             Categories:Nil];    [Application registerusernotificationsettings:Settings];    [Application registerforremotenotifications];} Else {    [Application Registerforremotenotificationtypes:(Uiremotenotificationtypebadge                                                     |Uiremotenotificationtypesound                                                     |Uiremotenotificationtypealert)];}

As you can see, IOS 8 divides the registration of the original one step remotenotification into two parts, part of which is registering the newly introduced "uiusernotificationsettings", and the other part is remotenotifications. Why should Apple design this?

Simply put, Apple unifies remotenotification and localnotification in IOS 8. The two notifications will be unified by Uiusernotificationsettings to manage the user interface related things: tags, sounds, and reminders. In addition to the unified user interface notification, Uiusernotificationsettings also introduced the uiusernotificationcategory, allowing users to conveniently directly in the Notification To perform some quick actions on the operation (action). I haven't played this part yet, so I don't have much to say.

In short, it's amazing how Apple is trying to get the old API straight out of the process to drive new technology ...

changes of unwind Segue

Unwind Segue is a technique that I really like and practical in Storyboard. With unwind, it is convenient to fallback between viewcontroller at the same level (through Push) and at different levels (through Modal), as long as the previous viewcontroller has a specific unwind, then the current V Iewcontroller execution of this unwind, will jump back to a previous viewcontroller, regardless of the interval of a few, can accurately jump back.

Like this technology is mainly because unwind is more flexible than Delegate, Viewcontroller can be separated in the middle of several, do not need to use Delegate associated with, as long as the implementation of a specific unwind method can be.

However, in IOS 8, unfortunately, unwind no longer works as well as before: If your viewcontroller is based on Navigationcontroller, now it supports only the same level of Viewcontroller jumps (that is, by means of Push) and does not support reciprocal jumps between different levels of viewcontroller (i.e., by Modal form).

Apple does not have any depcated Warning, directly let Modal form of viewcontroller under the unwind do not work, no errors and hints ...

On this, StackOverflow has a discussion: unwind Segue not working in IOS 8

So far, there is no good way (including the accepted Answer actually not), so far I have found that the best way is to rewrite the relevant code, and then use the delegate to achieve. If you have a better way, please remember to tell me.

PostScript

Since I'm pretty much iOS 7, I'm not sure I've ever started an iOS development before, and I don't know if Apple used iOS 5, iOS 6, iOS 6 and iOS 7 to get a similar API to not work, not a step-deprec. The process of ated.

In short this time let me real experience will be in the new and old version of the pain as a developer when switching, and do not say that the destruction of the API compatibility is not appropriate, just IOS 8/xcode 6 in a variety of frustrating Bug let a person enough headache, or hope that Apple in Xcode 6.1 to change the problem Less.

Next, I'm going to fit Manico's Yosemite style ...


Two things to do with IOS 8: remote push and unwind Segue

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.