真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

IOS8本地推送補(bǔ)充

-

目前成都創(chuàng)新互聯(lián)已為近1000家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)站空間、綿陽服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計、競秀網(wǎng)站維護(hù)等服務(wù),公司將堅持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    _window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];

    _window.backgroundColor = [UIColor whiteColor];

    [_window makeKeyAndVisible];

    ScrollContentViewController * scrollcontentView = [[ScrollContentViewController alloc]init];

    UINavigationController * navigationController = [[UINavigationController alloc]initWithRootViewController:scrollcontentView];

    _window.rootViewController = navigationController;

    UIView * statusBarView = [[UIView alloc]initWithFrame:CGRectMake(0, -20, 320, 64)];

    statusBarView.backgroundColor = [UIColor colorWithRed:0 green:122/255.0f blue:247/255.0f alpha:1];

    [navigationController.navigationBar addSubview:statusBarView];

    [application setStatusBarHidden:NO];

    [application setStatusBarStyle:UIStatusBarStyleLightContent];

    //注冊推送(ios 8

    if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)])

    {

        [[UIApplication   sharedApplication]registerUserNotificationSettings:[UIUserNotificationSettingssettingsForTypes:UIUserNotificationTypeAlert |UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil]];

    }

    return YES;

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

{

    //接受本地推送

    NSLog(@"%@",notification);

    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"iWeibo" message:notification.alertBody delegate:nil cancelButtonTitle:@"確定"otherButtonTitles: nil];

    [alert show];

    //圖標(biāo)上的數(shù)字減1

    application.applicationIconBadgeNumber -=1;

    

    //解除本地推送

    //獲得uiapplication

    UIApplication * app = [UIApplication sharedApplication];

    //獲取本地推送數(shù)組

    NSArray * localArray = [app scheduledLocalNotifications];

    //聲明本體通知對象

    UILocalNotification * localNotification;

    if (localArray)

    {

        for (UILocalNotification * noti in  localArray)

        {

            NSDictionary * dict = noti.userInfo;

            if (dict)

            {

                NSString * inKey = [dict objectForKey:@"key"];

                if ([inKey isEqualToString:@"對應(yīng)的key"])

                {

                    if (localNotification)

                    {

                        localNotification = nil;

                    }

                    break;

                }

            }

        }

        //判斷是否找到已經(jīng)存在的相同key的推送

        if (!localNotification)

        {

            //不存在初始化

            localNotification = [[UILocalNotification alloc]init];

        }

        if (localNotification)

        {

            //不推送取消推送

            [app cancelLocalNotification:localNotification];

            return;

        }

    }

}

.....

- (void)viewDidLoad {.....}

-(void)SendNotification:(UIButton *)sender

{  //創(chuàng)建本地推送

    NSDate * now = [NSDate date];

    UILocalNotification * reminderNotification = [[UILocalNotification alloc]init];

    //設(shè)置推送時間

    [reminderNotification setFireDate:[now dateByAddingTimeInterval:10]];

    //設(shè)置時區(qū)

    [reminderNotification setTimeZone:[NSTimeZone defaultTimeZone]];

    //設(shè)置userinfo方便在之后需要撤銷的時候使用

    reminderNotification.userInfo = [NSDictionary dictionaryWithObject:@"name" forKey:@"key"];

    //設(shè)置推送內(nèi)容

    [reminderNotification setAlertBody:@"Don't forget to Show Out !"];

    [reminderNotification setAlertAction:@"Show Out"];

    [reminderNotification setCategory:@"alert"];

    //設(shè)置推送聲音

    [reminderNotification setSoundName:UILocalNotificationDefaultSoundName];

    //顯示在icon上的紅色圈子的數(shù)子

    [reminderNotification setApplicationIconBadgeNumber:1];

    //添加推送到UIApplication

    [[UIApplication   sharedApplication]scheduleLocalNotification:reminderNotification];

    

    NSLog(@"currentUserNotificationSettings = %@",[[UIApplication sharedApplication]currentUserNotificationSettings]);

    [[UIApplication sharedApplication] isRegisteredForRemoteNotifications ];

    

    UIAlertView * successAlert = [[UIAlertView   alloc]initWithTitle:@"Reminder" message:@"Your Reminder has been Scheduled" delegate:nilcancelButtonTitle:@"OK Thanks ! " otherButtonTitles: nil];

    [successAlert show];

 

}

IOS8定位問題 

 /**

 *1:先在info.plist中添加NSLocationAlwaysUsageDescription設(shè)置為字符串類型,為YES;

 *2:info.plist中添加NSLocationWhenInUseUsageDescription設(shè)置為字符串類型,為YES;

 *3:創(chuàng)建CLLocationManager對象

 *4    //創(chuàng)建對象

 *           self.locationManager=[[CLLocationManager alloc]init];

 *           //設(shè)置代理

 *          self.locationManager.delegate=self;

 *           //請求

 *          [self.locationManager  requestWhenInUseAuthorization];

 *           //類型

 *           self.locationManager.desiredAccuracy=kCLDistanceFilterNone;

 *           //開始

 *          [self.locationManager  startUpdatingLocation];

 *5:寫代理方法-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status

 */

    //創(chuàng)建對象

    self.locationManager=[[CLLocationManager alloc]init];

    //設(shè)置代理

    self.locationManager.delegate=self;

    //請求

    [self.locationManager  requestAlwaysAuthorization];

    //類型

    self.locationManager.desiredAccuracy=kCLDistanceFilterNone;

    //開始定位

    [self.locationManager  startUpdatingLocation];

    

#pragma mark 代理方法

//此方法會在用戶授權(quán)狀態(tài)改變時調(diào)用

-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status

{

    switch (status)

    {

        case kCLAuthorizationStatusNotDetermined:

            if ([self.locationManager  respondsToSelector:@selector(requestWhenInUseAuthorization)])

            {

                [self.locationManager requestAlwaysAuthorization];

            }

            break;

        default:

            break;

    }

}

 //更新位置的代理方法

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray*)locations

{   //use locations

    NSLog(@"=========%@",locations);

    //根據(jù)經(jīng)緯度解析成位置

    CLGeocoder *geocoder=[[CLGeocoder alloc]init];

    [geocoder reverseGeocodeLocation:locations[0] completionHandler:^(NSArray*placemark,NSError *error)

     {

         CLPlacemark *mark=[placemark objectAtIndex:0];

        

       NSString *  title=[NSStringstringWithFormat:@"%@%@%@",mark.subLocality,mark.thoroughfare,mark.subThoroughfare];

       NSString   * subTitle=[NSString stringWithFormat:@"%@",mark.name];//獲取subtitle的信息

         

         NSLog(@"``````%@~~~~~~~%@_______",title,subTitle);

         

     } ];

}

//定位失敗信息

-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error

{

    

    NSLog(@"--------%@---------",error);

}



名稱欄目:IOS8本地推送補(bǔ)充
標(biāo)題路徑:http://weahome.cn/article/pijpic.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部