标签: apple-push-notifications

模拟器上的设备令牌请求没有响应

我是 iphone 技术的新手,现在我正在使用一个需要实现推送通知的应用程序。

我按照链接:

http://mobiforge.com/developing/story/programming-apple-push-notification-services#comment-7850

另外,使用了以下代码:

 NSLog(@"Registering for push notifications...");
    [[UIApplication sharedApplication]
  registerForRemoteNotificationTypes:
 (UIRemoteNotificationTypeAlert |
  UIRemoteNotificationTypeBadge | 
  UIRemoteNotificationTypeSound)];

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken 
{
    NSString *str = [NSString stringWithFormat:@"Device Token=%@",deviceToken];
    NSLog(str);
}

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err 
{ 
    NSString *str = [NSString stringWithFormat: @"Error: %@", err];
    NSLog(str);    
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
{
    for (id key in userInfo) 
 {
        NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
    }    
}
Run Code Online (Sandbox Code Playgroud)

事情是,当我运行程序时,我应该根据代码在调试器窗口中获取设备令牌,而不是我收到如下错误:

" 注册错误。错误:Error Domain=NSCocoaErrorDomain Code=3010 "模拟器不支持远程通知" UserInfo=0x6e055a0 {NSLocalizedDescription=模拟器不支持远程通知} "

我应该如何解决这个问题?

请帮帮我。 …

push-notification apple-push-notifications ios ios-simulator

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

在服务器数据库更新时通知 iOS 应用程序的最佳方式

我对编程很陌生,我找不到解决我的问题的有效方法。有人能指出我正确的方向吗?

我有一个严重依赖服务器数据的应用程序。服务器上的数据对于每个用户都是唯一的,并且可能每分钟更改一次,也可能每几小时更改一次。目前,当应用程序变为活动状态时,我正在更新本地数据,但我还需要一种通知应用程序以在应用程序保持活动状态且服务器上的数据发生更改时触发更新的方法。我想了几个解决方案:

1) NSTimer 设置为一分钟并触发 url 请求以检查服务器上是否有新数据。比较 lastModified 值后的服务器将返回新数据(如果可用)。

  • 我真的不喜欢这个解决方案,因为我不想让我的服务器因请求数量而过载,尤其是数据库中的数据可能每隔几个小时甚至更长的时间就会改变。

2)APNS - 每次数据更改时从服务器发送通知,然后在收到通知时使用服务器数据库更新本地数据。

  • 这似乎是一个很好的解决方案,但前提是可以限制当应用程序处于活动状态时接收远程通知。据我所知这是不可能的,正如我之前提到的,数据甚至每分钟都可能发生变化,所以我不想在应用程序未运行时向用户发送大量通知。

3) 使用 NSStream/CFStream 的 TCP 套接字?

  • 这是我以前从未做过的事情,所以我什至不确定我是否朝着正确的方向研究这个。

web-services tcp apple-push-notifications ios

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

在单个应用程序中接收某些应用程序的所有通知(Android 和 IOS)

首先,我不是移动开发者。我想知道当同一手机上的其他应用程序收到通知时,是否可以在不同的手机应用程序中收到通知?如果是,请给我一个概述。

任何帮助表示赞赏

PS:我是一名网络开发人员,所以我能够理解拦截http请求

android push-notification apple-push-notifications ios

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

使用 Xamarin 和 Azure 应用服务移动应用的 iOS/APNS 的 Azure 通知中心 InvalidToken 错误

我正在尝试将通知添加到我的 Azure 移动应用程序(Azure 应用程序服务移动应用程序),并且正在努力让它们与 iOS 一起使用。我已经成功地让他们为 Android 工作。

我已按照在线说明设置 Apple 证书和配置文件:

https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter5/ios/

iOS 应用程序正在向 APNS 注册并收到设备令牌。然后我删除“<”和“>”字符以及空格,并将注册发送到通知中心。

 var templates = new JObject
 {
     ["genericMessage"] = new JObject
     {
         {"body", "{\"aps\":{\"alert\":\"$(message)\"}}"}
     }
 };

 var push = m_MobileServiceClient.GetPush();
 await push.RegisterAsync(token, templates);
Run Code Online (Sandbox Code Playgroud)

当我发送第一个推送通知请求时...

 var notification = new Dictionary<string, string> { { "message", "Test notification message" } };
 await m_Hub.SendTemplateNotificationAsync(notification);
Run Code Online (Sandbox Code Playgroud)

...注册已从通知中心删除。

我已将 Azure 通知中心上的定价层提高到标准,并使用它来查找存储在存储帐户中的跟踪,它显示“InvalidToken”作为来自 APNS 的错误。

我做过/检查过的事情:

  • 通知中心作为 APNS 凭据设置为开发证书(从 Apple 开发人员门户为启用推送通知的非通配符应用 ID 创建和导出)和沙盒环境。
  • iOS App 项目设置为使用开发者身份和 App ID 链接到的配置文件:

iOS 项目捆绑签名设置

  • 我在 Info.plist 中添加了以下内容(并非所有说明都包含此内容,但其他文章建议它是必需的)

    <key>aps-environment</key>
    <string>development</string> …
    Run Code Online (Sandbox Code Playgroud)

push-notification xamarin.ios apple-push-notifications azure-mobile-services azure-notificationhub

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

Swift:从 AppDelegate 中的 UNTextInputNotificationAction 获取内容

我正在使用Xcode 9.4.1 (9F2000)Swift

我有这个代码AppDelegate

func showPushButtons(){
    let replyAction = UNTextInputNotificationAction(
        identifier: "reply.action",
        title: "Reply to message",
        textInputButtonTitle: "Send",
        textInputPlaceholder: "Input text here")

    let pushNotificationButtons = UNNotificationCategory(
        identifier: "allreply.action",
        actions: [replyAction],
        intentIdentifiers: [],
        options: [])

    UNUserNotificationCenter.current().setNotificationCategories([pushNotificationButtons])
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {

    let action = response.actionIdentifier
    let request = response.notification.request
    let content = response.notification.request.content.userInfo

    print("\(action)\(request)\(content)")

    if let aps = content["aps"] as? [String: AnyObject] {
        dump(aps)
    } …
Run Code Online (Sandbox Code Playgroud)

xcode apple-push-notifications ios swift unusernotificationcenter

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

iOS 应用程序能否同时使用基于证书和基于令牌的 APNs 连接?

我们目前正在为现有应用准备更新,该应用通过 Firebase 提供推送通知,该应用使用基于令牌的 APNs 连接。

由于后端的变化,我们希望过渡到基于证书的 OneSignal。

由于应用将作为更新发布,我们希望在过渡期间通过 Firebase 保持推送,而更新版本应该能够通过 OneSignal 接收推送。

我的问题是:对于一个 App-ID,我可以同时使用两者吗?还是会互相干扰?

苹果的文档提到

要发送通知,您的提供商服务器必须使用 HTTP/2 和 TLS 与 APN 建立基于令牌或基于证书的信任。

但不要说同时实施两者。

apple-push-notifications ios

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

fastlane nuke 是否也删除推送证书

我们丢失了匹配加密密码,不得不核对我们现有的配置文件。我想确保跑步

fastlane nuke development
fastlane nuke distribution
fastlane nuke adhoc
Run Code Online (Sandbox Code Playgroud)

因此,核对旧证书不会删除我们针对相同应用程序的 APNS 推送证书。

或者我是否必须创建新的推送证书并发送给我们的后端团队?

apple-push-notifications ios fastlane fastlane-match

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

前台 Swift 4.2 中的 IOS 推送通知

我正在开发 IOS 应用程序,我正在使用 Parse SDK 处理推送通知。当我的背部在后台时,我能够收到通知。现在,即使我的应用程序在前台,我也想收到通知。我为它搜索了很多代码,但它不适合我当前的 AppDelegate 类。

即使我的应用程序在前台,如何获取推送通知?

 @UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Thread.sleep(forTimeInterval: 3.0)
        // Override point for customization after application launch.

        let configuration = ParseClientConfiguration {
            $0.applicationId = "asdasdasd"
            $0.clientKey = "asdasdasdas"
            $0.server = "https://parseapi.back4app.com"
        }
        Parse.initialize(with: configuration)

        UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate

        UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) {
            (granted, error) in
            print("Permission granted: \(granted)")
            guard granted else { return }
            self.getNotificationSettings() …
Run Code Online (Sandbox Code Playgroud)

foreground apple-push-notifications ios swift

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

强制退出应用程序在后台模式下的静音通知

我的问题是:当用户强制退出(滑动)应用程序时,我无法使无提示通知工作!

我想以下是一个事实:如果应用程序被用户强制退出(刷掉),静默推送(使用content-available:1)不会触发,application(_:didReceiveRemoteNotification:fetchCompletionHandler:)也不会触发任何其他方法(它不会启动应用程序)!谁能证明这是错误的?

我已确保已启用Background Mode: Remote Notifications

但是如果非静音通知对我不起作用怎么办?我需要静默的,我需要在展示之前能够运行一些检查!如果我想在收到来自远程服务器的通知后检查是否有正确的用户登录到我的应用程序,该怎么办?(因为我不能保证当他退出时他成功地让服务器知道,所以我假设服务器不确定)

在我的情况下采取什么正确的方法?

类似的事情有很多问题,但涉及的人并不多,不知道为什么?我不相信我有这么罕见的情况。也许我解决这类问题的基本方法是错误的?在Android平台上似乎完全没有问题!

我使用 FCM 作为发送通知的中心点,所以如果你说 PushKit 可以解决我的问题,FCM 不支持 VoIP 证书太糟糕了。但是,我想知道,PushKit 真的能解决这个问题吗?或者苹果只是这样设计的,当用户强制退出一个应用程序时,这意味着这个应用程序必须完全关闭才能推送远程通知?!

我不认为这是Firebase 静默通知的副本不会启动关闭的 iOS 应用程序,因为我在这里问的是如果您想检查通知所针对的用户是否对应于用户登录到应用程序?如果事实证明在 iOS 平台上绝对没有解决方案,则可以认为是重复的。

push-notification apple-push-notifications uiapplicationdelegate ios swift

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

iOS 上的 Firebase 云消息传递无法正常工作

我添加到我的项目Firebase Cloud Messaging以接收和发送推送通知。我按照 Google 原始教程中的步骤进行操作。结果令人兴奋,我可以在我的设备上收到推送通知- 我将其发布到TestFlight - 出现问题

我意识到我需要创建不同的证书。(???) 然后我从 Firebase Cloud 消息传递中删除了我的密钥 (.p8) 并重新创建了它(开发也是如此)+ 我重新创建了相同的开发配置文件(我撤销了旧配置文件),我从教程中重复了过程,但现在我不能即使在我的设备上能收到推送通知,无论是在 TestFlight 上。

任何人都可以帮我解决这些问题吗?

  1. 我应该创建哪个证书/配置文件?现在,我已经为开发创建了 .p8 密钥和用于开发的配置文件(不再工作)
  2. 我应该更改代码中的某些内容吗?我发现我应该在某个地方将 URL 从沙盒更改为 prod,Firebase 会自动执行吗?设备令牌有问题吗?当我将 FCM 令牌复制/粘贴到控制台时,我什至无法收到测试通知。
  3. 可以从 Firebase 消息控制台发送静默推送通知吗?(我可以在 Firebase 控制台中设置所有必需的标头吗?)
  4. .p8 和 .p12 之间的区别?可以使用 .p8 密钥进行生产吗?

请帮我解决这个问题。谢谢!

[更新][已解决]完成此答案中的步骤并将Firebase 中的团队 ID 更改为来自 Apple 开发人员的相同团队 ID 后,我能够收到我的设备和所有 TestFlight 设备的通知。

push-notification apple-push-notifications ios firebase swift

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