作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在下面使用了 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;
这是屏幕截图:
错误:EXE_BAD_INSTRUCTION
for var pushManager:PushNotificationManager = PushNotificationManager.pushManager()
最佳答案
除非您按照 the documentation 中的这些重要步骤进行操作:
Add Pushwoosh.framework to your project.
Add -ObjC flag to the Linker Flags in your project.
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/
我是一名优秀的程序员,十分优秀!