關於重設IOS App請求推送的授權請求

來源:互聯網
上載者:User

標籤:

項目要添加推播通知,測試完本地通知後,發現測不了遠程通知。於是想重設授權請求。

以下是重設授權請求的方法:

方法一:

通用->還原->抹掉所有內容和設定

但是第一種方法很費時,抹掉內容估計得幾十分鐘。於是有了第二種方法。


方法二:

將App從裝置上刪除

        將裝置完全關機再重新啟動

開啟 設定->通用->日期與時間裡 將裝置時間拔快一天以上
將裝置再次完全關機再重新啟動

此時再安裝你的App可以像純新的流程一樣進行測試所有授權,


在設定中查看你的App授權選項也是全部重設。


附上註冊通知的代碼:


在AppDelegate的 didFinishLaunchingWithOptions方法中,添加代碼:

UIApplication *app = [UIApplication sharedApplication];        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];                if ([app respondsToSelector:@selector(registerUserNotificationSettings:)]) {            NSLog(@"8.0註冊通知");            [app registerUserNotificationSettings:settings];        } else {            NSLog(@"7.0及以下 註冊通知");            [app registerForRemoteNotificationTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound];        }

對於IOS8 ,新增了didRegisterUserNotificationSettings方法。如果要註冊RemoteNotification,需要在此方法裡添加註冊代碼:

if (IS_IOS8) {        [[UIApplication sharedApplication] registerForRemoteNotifications];    }
否則,如果註冊通知沒完成,就添加

[[UIApplication sharedApplication] registerForRemoteNotifications]
會引起以下warning:

Attempting to schedule a local notification ..... with an alert but haven't received permission from the user to display alerts




著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

關於重設IOS App請求推送的授權請求

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.