标签: apple-push-notifications

PHP技术查询APNs反馈服务器

有人可以澄清APN(Apple推送通知)所要求的内容吗?

文档说它会在连接完成后立即开始发送.这是否意味着我不fread()对其进行操作?

这是我当前尝试阅读它的代码.我没有放入fread()循环,因为我不知道什么响应表明"没有更多的记录可读",我不想在我的服务器上进行无限循环.

<?php
$apnsCert = 'HOHRO-prod.pem';

$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
stream_context_set_option($streamContext, 'ssl', 'verify_peer', false);

$apns = stream_socket_client('ssl://feedback.push.apple.com:2196', $error, $errorString, 60, STREAM_CLIENT_CONNECT, $streamContext);

echo 'error=' . $error;
echo 'errorString=' . $errorString;


$result = fread($apns, 38);
echo 'result=' . $result;


fclose($apns);
?>
Run Code Online (Sandbox Code Playgroud)

到目前为止,我得到的只是一个空回复.没有错误,所以它是连接.

我不知道null回复是否意味着没有数据,或者我的方法fread()是错误的.

谢谢

php stream fread push-notification apple-push-notifications

30
推荐指数
2
解决办法
3万
查看次数

在SWIFT中接收推送通知后控制哪个视图控制器加载

一旦我收到推送通知并轻扫以打开它,它就会打开我的应用而不是我想要的VC.

所以我的问题是如何加载我想要的VC?我知道如果应用程序是打开的,我会将VC移到另一个内部,didReceiveRemoteNotification但如果应用程序未打开,我该怎么做?或者它是否处于后台模式?

此外,我有两个不同的推送通知,因此我需要它移动两个不同的VC中的一个.如何区分不同的推送通知?

谢谢.

push-notification apple-push-notifications appdelegate

30
推荐指数
3
解决办法
3万
查看次数

推送通知未在iOS 10上收到,但在iOS 9及更早版本上运行

我有几个用Swift 2.2编写的应用程序,使用Xcode 7.3编译并在App Store上运行.这些应用程序使用Push Notifications,在iOS 9.3及更早版本中运行良好.

但是,在已升级到iOS 10的设备上,我的应用程序不会收到任何推送通知.仍在运行iOS 9的设备仍在接收通知.

考虑到它可能是证书或授权问题,我尝试了以下内容:将我的一个应用程序升级到Swift 2.3,添加了APS环境权利并在Xcode 8中编译它,但这没有任何区别.

在我的AppDelegate中,我仍然有现有的方法来注册推送通知,其中包括:

let notificationSettings = UIUserNotificationSettings(forTypes: [.Badge, .Sound, .Alert], categories:nil)
application.registerUserNotificationSettings(notificationSettings)
Run Code Online (Sandbox Code Playgroud)

这个注册似乎在iOS 10上也很成功,因为然后调用了应用程序didRegisterForRemoteNotificationsWithDeviceToken,所以我从APNS收到一个令牌.

问题是,当我向此设备发送推送通知时,永远不会调用应用程序didReceiveRemoteNotification.

现在,这里据说在UIApplicationDelegate方法已被弃用iOS上10,我应该实现userNotificationCenter(:didReceive:withCompletionHandler :)和userNotificationCenter(:willPresent:withCompletionHandler :)

问题是我不仅仅针对iOS 10.我仍然需要应用程序才能在iOS 8和9上运行,所以我怀疑这是实现这些方法的正确方法.

如何获取现有应用的推送通知以继续处理已升级到iOS 10的设备?我需要重写代码吗?我是否只需要更新一些证书或权利,并使用一些"新"设置在Xcode 8中重新编译?

push-notification apple-push-notifications ios swift xcode8

30
推荐指数
3
解决办法
4万
查看次数

什么时候调用didRegisterForRemoteNotificationsWithDeviceToken?

关于didRegisterForRemoteNotificationsWithDeviceToken有很多问题,但他们都回避了一个非常直接的问题,我似乎无法找到确切的答案.

对于以所有其他方式正确设置通知并具有适当网络连接的应用程序:何时调用didRegisterForRemoteNotificationsWithDeviceToken?一些可能的选择可能是:

  1. 每次应用程序启动时
  2. 只有在初始提示用户接受推送通知后
  3. 别的什么?

notifications apple-push-notifications ios

29
推荐指数
2
解决办法
3万
查看次数

重复Apple APNS推送通知?

我们一直在我们的应用程序上使用APNS,一段时间没有太多事件,突然我们的用户报告多次收到相同的推送通知.

我已经确认 - 乏味 - 我们的服务器只向Apple发送一次通知有效负载,然而通知在横幅和通知中心产生2个甚至3个相同的警报.

在iOS5和iOS6中都观察到了这一点.

以前有人见过这种现象吗?我是否可能错过了向有效负载添加唯一标识符的机会,这会阻止Apple向设备发送重复通知?谷歌的C2DM有这方面的collapse_key,但我找不到APNS中类似功能的参考.

php iphone push-notification apple-push-notifications ios

29
推荐指数
1
解决办法
5528
查看次数

PushSharp APNS生产:提供给包的凭据无法识别(开发工作正常)

我的应用程序刚刚在App Store上销售,但我的生产设备(从App Store安装了应用程序的设备)都没有获得推送通知.当我尝试向生产设备发送推送通知时,我收到此错误:

"The credentials supplied to the package were not recognized" 
(System.ComponentModel.Win32Exception)
Run Code Online (Sandbox Code Playgroud)

内部抛出此异常并陷入无限循环:

在此输入图像描述

它被抛出ApplePushChannel.cs文件的第539行:

    try
{
    stream.AuthenticateAsClient(this.appleSettings.Host, this.certificates, 
        System.Security.Authentication.SslProtocols.Ssl3, false);
    //stream.AuthenticateAsClient(this.appleSettings.Host);
}
catch (System.Security.Authentication.AuthenticationException ex)
{
    throw new ConnectionFailureException("SSL Stream Failed to Authenticate as Client", ex);
}
Run Code Online (Sandbox Code Playgroud)

这是Visual Studio输出中应用程序的输出:

...
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll
A first chance exception of type 'System.ObjectDisposedException' …
Run Code Online (Sandbox Code Playgroud)

ssl production-environment apple-push-notifications pushsharp

29
推荐指数
1
解决办法
2万
查看次数

自定义推送通知的iOS权限对话框

当iOS应用程序首次尝试注册推送通知时,系统会弹出一个权限对话框,要求用户获得接收推送通知的权限.是否可以自定义此对话框的文本,以解释为什么要搜索这些权限?

push-notification apple-push-notifications ios ios-permissions

28
推荐指数
4
解决办法
2万
查看次数

在适用于iOS的AdHoc Distribution Build上使用沙箱APNS

我一直在阅读一堆Apple的文档,以及许多其他SO问题,但是没有找到这个特定问题的答案.

我有一个现有的工作流程,可以为QA成员和beta测试人员生成AdHoc Distribution版本.现在我已经添加了对推送通知的支持,我希望这些通知路径也能够进行测试.

我的印象是开发人员构建,使用开发配置文件签名,为沙箱/开发APNS环境生成令牌,以及使用分发配置文件签署的分发版本(无论是发往AdHoc Distribution还是AppStore Distribution) ,为生产APNS环境生成令牌.我相信这可以通过打开不同的.mobileprovision文件并检查aps-environment密钥来确认.

我想知道是否有办法让我的AdHoc Distribution版本使用沙盒APNS环境,而不是生产APNS环境.

如果我真的希望QA和beta测试人员使用沙箱APNS,我是否必须以某种方式找到一种方法来允许他们运行开发版本而不是分发版本?

或者我对事物的运作方式的假设是什么?(参考这篇文章这篇文章)

iphone push-notification apple-push-notifications ios

28
推荐指数
2
解决办法
2万
查看次数

在iOS 10中不推荐使用UIUserNotificationSettings

我正在寻找在iOS 10中实现UIUserNotificationSettings的替代方法.

Apple文档提供了以下框架以供进一步使用.UNNotificationSettings链接在这里.

是否有人可以帮助我使用示例代码来使用UNNotificationSettings而不是UIUserNotificationSettings来实现下面的代码

let notificationSettings = UIUserNotificationSettings(
        forTypes: [.Badge, .Sound, .Alert], categories: nil)
    application.registerUserNotificationSettings(notificationSettings)
Run Code Online (Sandbox Code Playgroud)

xcode apple-push-notifications swift ios10 xcode8

28
推荐指数
1
解决办法
2万
查看次数

未调用iOS 10 UNUserNotificationCenterDelegate.推送通知无效

撕裂我的头发,以便在iOS10中使用推送通知.目前的设置:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool:

if #available(iOS 10.0, *) {

            let center = UNUserNotificationCenter.current()
            center.delegate = self
            center.requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in

                if error == nil {
                    print("DID REQUEST THE NOTIFICATION")
                    UIApplication.shared.registerForRemoteNotifications()
                }
            }
            print("DID SET DELEGATE")
        }
Run Code Online (Sandbox Code Playgroud)

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data):

print("DID REGISTER FOR A REMOTE NOTIFICATION AND THE TOKEN IS \(deviceToken.base64EncodedString())"           
let request = UpdatePushNotificationSubscription_Request(deviceToken: deviceToken)
updatePushNotificationSubscriptionWorker.updateSubscription(request)
Run Code Online (Sandbox Code Playgroud)

我已经检查过令牌是否正确地上传到后端,它确实匹配.

我也实施了:

    @available(iOS 10.0, *) …
Run Code Online (Sandbox Code Playgroud)

apple-push-notifications ios swift

27
推荐指数
3
解决办法
2万
查看次数