在决定是否向用户发送本地通知之前,我正在向我的应用发送静默推送通知,然后处理推送通知的内容.但是,在收到无声通知后,我无法从应用程序发出本地通知.
这是触发静默通知后appdelegate中的代码:
func application(application: UIApplication,
didReceiveRemoteNotification userInfo: [NSObject : AnyObject],
fetchCompletionHandler handler: (UIBackgroundFetchResult) -> Void) {
println("Did receive remote with completion handler")
var localNotification:UILocalNotification = UILocalNotification()
localNotification.alertAction = "view broadcast messages"
localNotification.alertBody = "Hello"
localNotification.fireDate = NSDate(timeIntervalSinceNow: 0)
localNotification.soundName = UILocalNotificationDefaultSoundName;
application.scheduleLocalNotification(localNotification)
handler(UIBackgroundFetchResult.NewData)
}
Run Code Online (Sandbox Code Playgroud)
但是,本地通知永远不会触发.
我启用了位置更新,后台提取和远程通知功能.
此外,当我的应用程序处于其后台状态时,它会侦听位置更新,然后在特定情况下使用本地通知向用户发出警报 - 这类似于代码.
那么为什么本地通知不会从中发出didReceiveRemoteNotification?
谢谢
我正在尝试将共享功能链接到我的swift应用程序中但是遇到了问题.我正在使用UIActivityViewController来共享图像和文本,但唯一可用的选项是:

我想要Facebook,Twitter和Whatsapp的选项(以及其余的!)但我无法弄清楚我做错了什么.
我也尝试过其他代码/源代码项目,但我遇到了同样的问题,但是如果我在设备上进行safari,它会在共享表上提供缺少的社交媒体选项.
这是我的代码:
func shareTextImageAndURL(#sharingText: String?, sharingImage: UIImage?, sharingURL: NSURL?) {
var sharingItems = [AnyObject]()
if let text = sharingText {
sharingItems.append(text)
}
if let image = sharingImage {
sharingItems.append(image)
}
if let url = sharingURL {
sharingItems.append(url)
}
let activityViewController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
activityViewController.excludedActivityTypes = [UIActivityTypeAirDrop, UIActivityTypeAddToReadingList]
if(activityViewController.popoverPresentationController != nil) {
activityViewController.popoverPresentationController?.sourceView = self.view;
var frame = UIScreen.mainScreen().bounds
// frame.height = frame.height / 2
var newFrame = CGRect(x: frame.origin.x, y: frame.origin.y, width: frame.width, height: frame.height / …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用apache安装overpass api作为Web服务器(http://wiki.openstreetmap.org/wiki/Overpass_API/install)
这是我的000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ExtFilterDefine gzip mode=output cmd=/bin/gzip
DocumentRoot /root/osm-3s_v0.7.4/html
# This directive indicates that whenever someone types http://www.mydomain.com/api/
# Apache2 should refer to what is in the local directory [YOUR_EXEC_DIR]/cgi-bin/
ScriptAlias /api/ /srv/osm3s/cgi-bin/
# This specifies some directives specific to the directory: [YOUR_EXEC_DIR]/cgi-bin/
<Directory "/srv/osm3s/cgi-bin/">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
#SetOutputFilter gzip
#Header set Content-Encoding gzip
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, …Run Code Online (Sandbox Code Playgroud)