doq1969 2015-08-20 13:27
浏览 182

APNS Apple推送服务通知未收到

I have used the code for APNS Apple Push Service Notification The message is sending from my server but it is not receiving to the device. Check the URL below:

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

Below is the messages I have obtained from the above link:

Thu, 20 Aug 2015 15:22:20 +0200 ApnsPHP[315874]: INFO: Trying ssl://gateway.sandbox.push.apple.com:2195... Thu, 20 Aug 2015 15:22:21 +0200 ApnsPHP[315874]: INFO: Connected to ssl://gateway.sandbox.push.apple.com:2195. Thu, 20 Aug 2015 15:22:21 +0200 ApnsPHP[315874]: INFO: Sending messages queue, run #1: 1 message(s) left in queue. Thu, 20 Aug 2015 15:22:21 +0200 ApnsPHP[315874]: STATUS: Sending message ID 1 [custom identifier: Message-Badge-3] (1/3): 154 bytes. Thu, 20 Aug 2015 15:22:21 +0200 ApnsPHP[315874]: INFO: Disconnected.

  • 写回答

1条回答 默认 最新

  • doupo1865 2015-08-20 13:33
    关注

    Did you checked in settings that Push notification are set to "ON"?

    And another thing push notification can only received in Real devices not in Simulators.

    You can send push notification from simulator (Because it is just a web service call.).

    -- UPDATE --

    The below code that requests for notifications.

    Write in 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];
        }
    

    Update below methods in you 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
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)