How to send a local push notification

Source: Internet
Author: User

How to send a local push notification

Push notifications are also part of the UI, so push notification objects start with the UI

Method Send notification Code method Controller-touchesbegan:withevent: Test, more appropriate, put into the Viewdidload method, the user's registration request has not completed the method called

    • Create a local notification
      //  创建本地通知对象  UILocalNotification *ln = [[UILocalNotification alloc] init];
    • Set local notification properties (recommended one for a property test run)
1. Set the contents of the notification (if this property is not set to send a notification) Ln.alertbody = @ "Xiaoming, your mother told you to go home for dinner!"; /2. Set the start time of the notification trigger ln.firedate = [NSDate datewithtimeintervalsincenow:3];//3. Set the time, interval ln.repeatinterval = Nscale for duplicate notifications ndarunitsecond;//4. Set recurring use calendar (user-set calendar) Ln.repeatcalendar = [Nscalendar currentcalendar];//nsstring * Const NSGRE Goriancalendar; Gregorian//NSString * Const Nschinesecalendar; Lunar Calendar//Ln.repeatcalendar = [[Nscalendar alloc] initwithcalendaridentifier:nschinesecalendar];//5. Set the number in the upper-right corner of the app icon Ln.app Licationiconbadgenumber = 3;//6. Set the click Push Notification to display when the interface is loaded, load the picture ln.alertlaunchimage = @ "";//7 Set the sound effect of the notification (only the real machine is valid) Local.sound Name = uilocalnotificationdefaultsoundname;//8 Set Some additional information Local.userinfo = @{@ "QQ": @ "55555", @ "info": @ "no"};//iOS8.0 New Properties//************************************//1. Set the area to enter or leave an area when triggered//cllocationcoordinate2d coordinate = Cllocati Oncoordinate2dmake (40.1,106.1);//ln.region = [[Clcircularregion alloc] Initwithcenter:coordinate radius:10.0 identifier:@ "AB"];//2. Set accessor leave an area to execute once//ln.regiontriggersonce = yes;//***************************************//iOS8.2 new Properties//LN.ALERTTITL E = @ "Notification Header";
    • Dispatching local notifications using app [UIApplication]
//  让应用调度通知    [[UIApplication sharedApplication] scheduleLocalNotification:ln];

How to send a local push notification

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.