【问题标题】:APNS Apple Push Service Notification not recievingAPNS Apple 推送服务通知未收到
【发布时间】:2015-08-20 13:27:22
【问题描述】:

我使用了 APNS Apple Push Service Notification 的代码 消息从我的服务器发送,但没有接收到设备。检查以下网址:

https://indiegirlworld.com/app/license_iphone/sample_push.php

以下是我从上述链接获得的消息:

2015 年 8 月 20 日星期四 15:22:20 +0200 ApnsPHP[315874]:信息:正在尝试 ssl://gateway.sandbox.push.apple.com:2195... 2015 年 8 月 20 日星期四 15:22:21 +0200 ApnsPHP[315874]:信息:已连接到 ssl://gateway.sandbox.push.apple.com:2195。 2015 年 8 月 20 日星期四 15:22:21 +0200 ApnsPHP[315874]:信息:发送消息队列,运行 #1:队列中剩余 1 条消息。 2015 年 8 月 20 日星期四 15:22:21 +0200 ApnsPHP[315874]:状态:发送消息 ID 1 [自定义标识符: Message-Badge-3] (1/3):154 字节。 2015 年 8 月 20 日星期四 15:22:21 +0200 ApnsPHP[315874]:信息:已断开连接。

【问题讨论】:

    标签: php ios objective-c


    【解决方案1】:

    您是否检查了推送通知设置为“开启”的设置?

    另一件事推送通知只能在真实设备中接收,而不能在模拟器中接收。

    您可以从模拟器发送推送通知(因为它只是一个网络服务调用。)。

    -- 更新--

    以下请求通知的代码。

    写入 appDelegate.m (didFinishLaunchingWithOptions:)

    if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
            NSLog(@"Requesting permission for push notifications..."); // iOS 8
            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeAlert | UIUserNotificationTypeBadge |
                                                    UIUserNotificationTypeSound categories:nil];
            [UIApplication.sharedApplication registerUserNotificationSettings:settings];
        }
        else {
            NSLog(@"Registering device for push notifications..."); // iOS 7 and earlier
            [UIApplication.sharedApplication registerForRemoteNotificationTypes: UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];
        }
    

    在您的 appDelegate.m 中更新以下方法

    - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
        // Store DeviceToken some way like in NSUserDefault (if needed to pass device token)
        // Write alert for success to register for push
    }
    
    - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { 
        // Write alert for failed to register for push
    }
    
    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
        // Write alert code that shows you have successfully received alert
        // after that maintain your push
    }
    

    【讨论】:

    • 我已经检查了所有这些推送通知设置为“ON”并在真实设备中检查。但是我仍然没有收到通知,您可以使用上面的 URL indiegirlworld.com/app/license_iphone/sample_push.php
    • 我还检查了apns-gcm.bryantan.info 上的设备令牌此在设备上发送和接收通知
    • 那么现在必须检查您实现的所有代码。因为推入没什么大不了的,但这是第一次实现非常典型..
    • 我已从github.com/immobiliare/ApnsPHP 获取代码并执行它,但没有显示错误
    • 您是否编写了发送推送的 php 代码,或者您正在使用其他社区(如 parse.com 或其他)提供的现成推送服务..
    猜你喜欢
    • 1970-01-01
    • 2012-12-03
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 2016-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多