<span id="Label3"></p><p><p>Recently watching iOS programming (4th Edition) (the textbook used by big Nerd ranch). This book is good, recommended, written very detailed, gradual, not to praise the idea of writing books for foreigners, really different from the People. Before learning android, read the "android programming the Big Nerd Ranch guide", Although the whole English look a bit slow, but slowly see feel very interesting, for a certain basis for beginners, harvest very big. Back to this native translation of iOS programming, Chinese translation of some words a bit awkward, I said a little memory ╭ (╯^╰) ╮, See the large section of chinese, patience is Insufficient.</p></p><p><p>To get to the point, I saw a place today, on the addition of local notification, when I built it with XCode6, there was an Error.</p></p><p><p>The program is to register a local notification in the response method of a Button's click Event. Here is the button response method in VIEWCONTROLLER.M.</p></p><pre><pre> <span style="color: #008080;">1 </span>-(ibaction) addreminder: (<span style="color: #0000ff;">id </span> Span style= "color: #000000;" ) Sender <span style="color: #008080;">2 </span> <span style="color: #000000;">{</span> <span style="color: # 008080; ">3 </span> nsdate *date=<span style="color: #000000;">self.datepicker.date; </span> <span style="color: #008080;">4 </span> uilocalnotification *note=<span style="color: #000000;">[[ Uilocalnotification alloc] init]; </span> <span style="color: #008080;">5 </span> note.alertbody=<span style="color: #800000;">@ "</span> <span style=" color: #800000; ">hypnotize me! </span> <span style="color: #800000;"> "</span> <span style="color: #000000;" ; < span> <span style="color: #008080;">6 </span> note.firedate=<span style="color: #000000;">date; </span> <span style="color: #008080;">7 </span> <span style="color: #000000;"> [[uiapplication sharedapplication] schedulelocalnotification:note]; </span> <span style="color: #008080;">8 </span>} </span></pre></pre><p><p>After the build, click on the button in the Emulator app without pop-up notifications, and Xcode gives the following debug Information.</p></p><pre><span style="color: #800080;"><span style="color: #800080;"></span> -</span>-<span style="color: #800080;"><span style="color: #800080;"></span> -</span>-<span style="color: #800080;"><span style="color: #800080;"></span> geneva</span> <span style="color: #800080;"><span style="color: #800080;">Ten</span></span>:<span style="color: #800080;"><span style="color: #800080;"></span> +</span>:<span style="color: #800080;"><span style="color: #800080;">31.538</span></span>hypnonerd[<span style="color: #800080;"><span style="color: #800080;">1185</span></span>:<span style="color: #800080;"><span style="color: #800080;">42048</span></span>] Attempting to schedule a local notification <uiconcretelocalnotification:<span style="color: #800080;"><span style="color: #800080;">0x7fcd5be826b0</span></span>>{fire date = thursday, July<span style="color: #800080;"><span style="color: #800080;">2</span></span>,<span style="color: #800080;"><span style="color: #800080;"></span> -</span>At<span style="color: #800080;"><span style="color: #800080;">Ten</span></span>:<span style="color: #800080;"><span style="color: #800080;"></span> +</span>:<span style="color: #800080;"><span style="color: #800080;"></span> in</span>AM China standard time, time zone = (<span style="color: #0000ff;"><span style="color: #0000ff;">NULL</span></span>), repeat interval =<span style="color: #800080;"><span style="color: #800080;">0</span></span>, repeat Count = uilocalnotificationinfiniterepeatcount, Next Fire date = (<span style="color: #0000ff;"><span style="color: #0000ff;">NULL</span></span>), User Info = (<span style="color: #0000ff;"><span style="color: #0000ff;">NULL</span></span>)} with a alert but haven<span style="color: #800000;"><span style="color: #800000;">'</span></span><span style="color: #800000;"><span style="color: #800000;">T received permission from the user to display alerts</span></span></pre><p><p>Confirm that the code input is not wrong, then why does it pop up such a message? Catch the last sentence in the message, there is a keyword "permission", instantly feel and write Android application time used to permission very much like Ah.</p></p><p><p>Check the internet, see this article "iOS8 system can not pop-up notice", said the IOS8 system changed the registration method (yes, I use the SDK is iOS 8.3). With the Author's method, it did solve the Problem.</p></p><p><p>But the author only wrote the solution, for reasons not much to Explain.</p></p><p><p>I go to Xcode's SDK Guide help document <em>Local and Remote Notification programming guide:registering, scheduling, and handling User Noti Fications</em></p></p><p><p>, you find Apple's description of the Issue.</p></p><p><p>In IOS 8 and later, apps either local or remote notifications must register the types of notifications they inten D to Deliver. The system then gives the user the ability to limit the types of notifications your app Displays. The system does not badge icons, display alert messages, or play alert sounds if any of these notification types is not E Nabled for your app, even if they is specified in the notification Payload.</p></p><p><p>In IOS8 and later iOS systems, if you want to use local notifications or remote notifications, you must register the notification type, and the system will not give the user permission to deliver the notification (display Notification) after the registration is Successful.</p></p><pre><pre><span style="color: #008080;">1</span> Uiusernotificationtype type=<span style="color: #000000;">uiusernotificationtypealert;</span> <span style="color: #008080;">2</span> Uiusernotificationsettings *settings=<span style="color: #000000;">[uiusernotificationsettings settingsfortypes:type categories:nil];</span> <span style="color: #008080;">3</span> [[uiapplication sharedapplication] registerusernotificationsettings:settings];</pre></pre><p><p>After registering for notification in applicationdelegate, the first time you run the app, a dialog box pops up asking the user if they want to allow the app to send notifications, and the app can send notifications when the user clicks "confirm".</p></p><p><p></p></p><p><p>Review yourself, feel that you have not developed to the official help document to find the habit of the answer, a problem is accustomed to find the Niang ╭ (╯^╰) ╮</p></p><p><p></p></p><p><p>IOS8 can't pop up local notifications?</p></p></span>
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