2017-01-15 34 views
0

嘿我希望在用戶按下按鈕而不是它後,提示推送通知一旦應用程序啓動請求。我會怎麼做?這是我在我的應用程序委託中所擁有的。特別提醒用戶何時允許推送通知

OneSignal.initWithLaunchOptions(launchOptions, appId: "myKey") 

if application.responds(to: #selector(UIApplication.registerUserNotificationSettings(_:))) { 
     let settings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil) 


     application.registerUserNotificationSettings(settings) 
     application.registerForRemoteNotifications() 

    } else { 

     let types: UIRemoteNotificationType = [UIRemoteNotificationType.badge, UIRemoteNotificationType.alert, UIRemoteNotificationType.sound] 
     application.registerForRemoteNotifications(matching: types) 
    } 

回答

0

難道你不能只使用鏈接到IBAction的UIButton?這樣你就需要將應用程序更改爲UIApplication.shared

+0

試過了,但它似乎仍顯示應用程序何時啓動。它有一些事情要做w/OneSignal.initWithLaunchOptions(launchOptions,appId:「myKey」),但我不知道我應該用什麼來替代launchOptions –

相關問題