gpt4 book ai didi

iphone - 推沃什 : Swift Code

转载 作者:行者123 更新时间:2023-11-28 07:13:21 24 4
gpt4 key购买 nike

我在下面使用了 push whoosh swift 代码,但它崩溃了。

        if(UIApplication.instancesRespondToSelector(Selector("registerUserNotificationSettings:")))
{
application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: UIUserNotificationType.Sound | UIUserNotificationType.Alert | UIUserNotificationType.Badge, categories: nil))
}
else //iOS7
{
application.registerForRemoteNotificationTypes( UIRemoteNotificationType.Badge |
UIRemoteNotificationType.Sound |
UIRemoteNotificationType.Alert )
}

var pushManager:PushNotificationManager = PushNotificationManager.pushManager();
pushManager.delegate = self;

// handling push on app start
PushNotificationManager.pushManager().handlePushReceived(launchOptions);

// make sure we count app open in Pushwoosh stats
PushNotificationManager.pushManager().sendAppOpen();

// register for push notifications!
PushNotificationManager.pushManager().registerForPushNotifications();

UIApplication.sharedApplication().applicationIconBadgeNumber = 1;
UIApplication.sharedApplication().applicationIconBadgeNumber = 0;

这是屏幕截图:enter image description here

错误:EXE_BAD_INSTRUCTION for var pushManager:PushNotificationManager = PushNotificationManager.pushManager()

最佳答案

除非您按照 the documentation 中的这些重要步骤进行操作:

  1. Add Pushwoosh.framework to your project.

  2. Add -ObjC flag to the Linker Flags in your project.

  3. In your Info.plist add the following key Pushwoosh_APPID with your Pushwoosh Application ID string value

...那么您的问题很可能是 PushNotificationManager.pushManager() 正在返回 nil,当您尝试分配结果为非可选值。

关于iphone - 推沃什 : Swift Code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27543006/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com