标签: apple-push-notifications

iOS:针对特定View Controller类的didReceiveRemoteNotification

场景 =我有一个具有消息传递功能的应用程序.在发送消息时,还将向接收者的电话发送推送通知.我希望用户每当用户接收带有"警报"(在屏幕上显示消息),"徽章"(红色圆圈中的应用程序图标徽章编号)和"声音"(在推送时播放的声音)的推送通知是不是看Instant Messenger的屏幕-当用户IS的即时通讯屏幕上,我希望用户收到"徽章"和"声音" ONLY.

为什么我不想在Instant Messenger屏幕上发送"警报"? 因为当消息加载到tableView时,即时消息屏幕已经向用户显示消息.当他们不得不一直点击它以便在屏幕上再次阅读时,我为什么要将IM推送到他们的屏幕上并显示"警报"?没有意义.

为什么我只希望用户在IM屏幕上收到"徽章"? 这是因为我的应用程序不断检查要增加的应用程序的徽章计数,以便在引发应用程序徽章时刷新表格视图.我还希望播放"声音"以通过声音通知用户Push已进入他们的手机.

需要注意的事项 =我的应用程序基于一个架构,其中包含一个Tab栏控制器,其中包含每个选项卡的导航控制器.如果这有所作为.

编辑 - 总结和简化的问题.

你是怎么做到的?...(不是真正的代码)

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {

    if (isOnInstantMessagingScreen) {

        //Disable Push "Alert" messages
        //Enable Push "Badge"
        //Enable Push "Sound"
    }

    else {

        //Enable Push "Alert" messages
        //Enable Push "Badge"
        //Enable Push "Sound"
    }
Run Code Online (Sandbox Code Playgroud)

objective-c push-notification apple-push-notifications ios parse-platform

0
推荐指数
1
解决办法
2948
查看次数

当我使用我的应用程序时,如何关闭其他应用程序的推送通知

我创建了一个从我的服务器接收推送通知的应用程序.同时,如果其他应用程序正在发送推送通知(例如,whatsaap,twitter),则在我使用我的应用程序时会显示通知.除了应用程序的推送通知之外,我想隐藏所有其他应用程序的推送通知.这可以在iOS上完成吗?我希望我的应用只能从我的服务器接收推送通知,但不能从其他应用程序接收.

提前致谢.

iphone apple-push-notifications ios

0
推荐指数
1
解决办法
857
查看次数

将Parse推送通知集成到Xcode 7项目(Swift)

我正在将Parse Push通知集成到一个应用程序中,并且已经陷入了Swift 2.0转换.代码是:

if application.respondsToSelector("registerUserNotificationSettings:") {
            let userNotificationTypes: UIUserNotificationType = [.Alert, .Badge, .Sound]
            let settings = UIUserNotificationSettings(forTypes: userNotificationTypes, categories: nil)
            application.registerUserNotificationSettings(settings)
            application.registerForRemoteNotifications()
        } else {
            let types: UIUserNotificationType = [.Badge, .Alert, .Sound]
            application.registerForRemoteNotificationTypes(types)
        }
Run Code Online (Sandbox Code Playgroud)

Xcode抱怨"无法将类型'UIUserNotificationType'的值转换为预期的参数类型'UIRemoteNotificationType'

apple-push-notifications ios parse-platform swift2

0
推荐指数
1
解决办法
1241
查看次数

iOS通知可以推送文件吗?

我可以以某种方式在iOS上发送带有推送通知的整个文件,或者向设备发送通知以从服务器下载文件.

设备需要在它的OWN上执行此操作,无需用户交互,我需要它才能在不更新商店中的应用程序的情况下工作.

那可能吗?如果没有任何建议/替代方案是受欢迎的.

objective-c apple-push-notifications ios

0
推荐指数
1
解决办法
105
查看次数

WhatsApp如何加密iOS上的推送通知?

最近,WhatsApp 为所有平台集成了用于端到端加密的信号协议.

我和朋友一起尝试了,它说加密被激活了.在iOS 8上关闭应用程序并禁用后台任务后,我朋友的推送通知仍显示该消息.

问题: WhatsApp是否加密了APNS消息?如果是,他们如何显示文字?iOS上是否有处理推送通知的方法?

提前致谢!

encryption apple-push-notifications ios whatsapp

0
推荐指数
1
解决办法
1445
查看次数

不调用NotificationService Extension(ios)

我试图在我的应用程序上创建一个新的NotificationService扩展,因此我直接在Project Navigator中删除了现有的Notification Service Extension,包括NotificationService.swift及其文件夹,并尝试创建NotificationService Extension的新目标.

创建新的扩展后,新的NotificationSerivce.swift中的方法"didreceive"从未被调用过.

我怎么能让他们工作?

push-notification apple-push-notifications ios swift

0
推荐指数
1
解决办法
2603
查看次数

在iOS应用中显示通知当应用程序在前景/活动在swift 3

我正在尝试在应用处于活动状态时显示横幅通知.我使用了给定的方法但没有结果,横幅通知仅在应用关闭时出现:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
    print("Push notification received: \(userInfo)")

    if application.applicationState == .active {
       print("active")
       let localNotification = UILocalNotification()
       localNotification.userInfo = userInfo
       localNotification.alertAction = "Test"
       localNotification.soundName = UILocalNotificationDefaultSoundName
       localNotification.alertBody = "Notification test!!"
       localNotification.fireDate = Date()
       UIApplication.shared.scheduleLocalNotification(localNotification)
     }
}
Run Code Online (Sandbox Code Playgroud)

它打印"活动"但通知未显示.我错过了任何一步吗?

谢谢.

push-notification apple-push-notifications ios swift

0
推荐指数
1
解决办法
6257
查看次数

使用APNS发送远程推送通知的发送报告 - IOS

我正在使用APNS发送远程推送通知.要求是将通知发送给应用程序用户(即使用户没有点击通知或甚至看不到通知),根据通知ID i向Web服务器发送送达回执(即调用Web服务)接收.

APNS没有提供交付报告.他们是APNS的反馈服务,但也不提供交付报告.

所以我想知道获得远程推送通知的交付报告的可能方法是什么.如果我能够在APP deligate或其他任何其他远程推送通知到达时执行自定义方法,即使APP在后台或由用户终止,那么它将解决我的问题.

任何帮助将受到高度赞赏.

下面是我目前使用的代码,当应用程序处于后台时,它无法正常工作.

我写了一个自定义方法

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
Run Code Online (Sandbox Code Playgroud)

向服务器发送确认收到通知的确认.当应用程序在前台时,所有功能都完美地执行.但是当应用程序处于后台时会出现问题.写的自定义方法

 -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
Run Code Online (Sandbox Code Playgroud)

直到用户通过点击通知栏打开应用程序才执行,如果用户通过点击应用程序图标而不是通知栏打开应用程序,则不会执行.

iphone objective-c push-notification apple-push-notifications ios

0
推荐指数
1
解决办法
2061
查看次数

使用PHP的APNS显示SSL损坏的管道错误

在我的项目中有大约500个iOS用户.向他们发送推送通知显示以下错误.

Severity: Warning
Message:  fwrite(): SSL: Broken pipe
Message:  fwrite(): SSL operation failed with code 1. OpenSSL Error messages:
error:1409F07F:SSL routines:ssl3_write_pending:bad write retry
Run Code Online (Sandbox Code Playgroud)

一些令牌工作正常,结果整数如8.18,因为从第一个令牌,结果0显示上述错误.是否由于无效令牌?.我无法区分生产和开发令牌.请帮助.谢谢提前.我的代码

public function connectApns(){

            try{

                $ctx = stream_context_create();
                stream_context_set_option($ctx, 'ssl', 'local_cert',$_SERVER['DOCUMENT_ROOT'].'/webservice/application/libraries/ck.pem');
                stream_context_set_option($ctx, 'ssl','passphrase', '1234');
                $this->fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);


                    if($this->fp){
                        return TRUE;
                    }else{
                        echo $errstr;
                        return FALSE;
                    }
                }
            catch(Exception $e1){

                echo $e1->getMessage();

            }

        }

    public function iOS($data,$columnName){

            $ids = array();
            $tokens = array();
            $sql = "SELECT user_id FROM tp_notification WHERE ";
            if($columnName == "job"){ …
Run Code Online (Sandbox Code Playgroud)

php ssl apple-push-notifications

0
推荐指数
1
解决办法
455
查看次数

未调用UNNotificationServiceExtension的didRecieve

我逐步移动以获得丰富的推送通知。他们来了 :

  1. 使用plist创建了Notification服务扩展:

在此处输入图片说明

NotificationService didRecieve

override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {

        func failEarly() {
            contentHandler(request.content)
        }

        self.contentHandler = contentHandler
        bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

        // Get the custom data from the notification payload
        if let data = request.content.userInfo as? [String: AnyObject] {
            // Grab the attachment
            //            let notificationData = data["data"] as? [String: String]
            if let urlString = data["attachment-url"], let fileUrl = URL(string: urlString as! String) {
                // Download the attachment
                URLSession.shared.downloadTask(with: fileUrl) …
Run Code Online (Sandbox Code Playgroud)

apple-push-notifications ios swift unnotificationserviceextension

0
推荐指数
1
解决办法
1445
查看次数