在iPhone中没有收到任何推送通知

时间:2022-08-26 22:05:10

I have made a sample PushTest app for Push Notification using this tutorial.

我使用本教程制作了一个用于推送通知的PushTest应用程序示例。

And using above tutorial I got the message that 'PushTest' would like to send you Push Notification (exactly once) and after that I delete the app from iPhone, restart the iPhone but unable to get the same message again.

使用上面的教程,我得到了“PushTest”想要发送给你的消息(正好一次),然后我从iPhone上删除了应用程序,重新启动了iPhone,但是无法再次获得相同的消息。

I have run the script sample.php (updating the changes suggested) and got the message 'connected to APNS' & 'your message send'.

我已经运行了脚本示例。php(更新建议的更改)并获得消息“连接到APNS”和“您的消息发送”。

But I didn't receive any single push notification.

但我没有收到任何推送通知。

Please guide me where I am wrong?
Or what shod I try for push notification receive.

请指点我哪里错了?或者是我尝试的推送通知接收。

6 个解决方案

#1


25  

You will not receive Push only in 2 cases

您将不会收到推送仅在2个案例。

1.) If your application is in foreground.

1)。如果应用程序在前台。

2.) you device token is not valid for receiving the push notification please check both the condition if you still do not receive push please let me know. Thanks

2.)您的设备令牌对接收推送通知无效,如果您仍然没有收到推送,请检查两个条件,请告诉我。谢谢

#2


6  

Make sure you are using push notification enabled provisioning profile. and then check if you are sending token to server.

确保您使用的是推送通知启用配置文件。然后检查是否向服务器发送令牌。

#3


2  

I have followed the same tutorial.

我学过同样的教程。

Make sure your app is listed in notification center, and it's alert type is anything but not none.

确保您的应用程序在通知中心列出,它的警报类型是任何东西,但不是没有。

You need to check your notification in 3 conditions,

你需要在三个条件下检查你的通知,

When your app is open, in background, and when closed.

当你的应用程序打开时,在后台,当关闭时。

For that, you need to in check these methods

为此,需要检查这些方法

// To Register your device token
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken

//If your app is not able to register
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{}

//Your app receives push notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{

    UIApplicationState state = [application applicationState];

    // If your app is running
    if (state == UIApplicationStateActive)
    {

        //You need to customize your alert by yourself for this situation. For ex,
        NSString *cancelTitle = @"Close";
        NSString *showTitle = @"Get Photos";
        NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@""
                                                            message:message
                                                           delegate:self
                                                  cancelButtonTitle:cancelTitle
                                                  otherButtonTitles:showTitle, nil];
        [alertView show];
        [alertView release];

    }
    // If your app was in in active state
    else if (state == UIApplicationStateInactive)
    {
    }
}

#4


1  

Please check in your device's Settings if notifications for the application are on and ensure that the type of the notification is not 'None' in Notification Center.

如果应用程序的通知是打开的,请检查设备的设置,并确保通知中心中的通知类型不是“None”。

#5


1  

Make sure, that you select right provision profile 在iPhone中没有收到任何推送通知

确保您选择了正确的供应概要文件

and that your app is minimized. If app's not minimized use

你的应用被最小化了。如果应用程序没有最小化使用

 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    NSLog(@"info %@", userInfo);
}

Other useful information about issues.

关于问题的其他有用信息。

For TESTING pushes you can use APN Tester Free. Attention: insert token WITH spaces.

对于测试推送,您可以使用无APN测试器。注意:使用空格插入令牌。

#6


0  

I was not getting anything in:

我什么都没进:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any])

But my compiler stopped on breakpoint in

但是我的编译器在断点为

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)

#1


25  

You will not receive Push only in 2 cases

您将不会收到推送仅在2个案例。

1.) If your application is in foreground.

1)。如果应用程序在前台。

2.) you device token is not valid for receiving the push notification please check both the condition if you still do not receive push please let me know. Thanks

2.)您的设备令牌对接收推送通知无效,如果您仍然没有收到推送,请检查两个条件,请告诉我。谢谢

#2


6  

Make sure you are using push notification enabled provisioning profile. and then check if you are sending token to server.

确保您使用的是推送通知启用配置文件。然后检查是否向服务器发送令牌。

#3


2  

I have followed the same tutorial.

我学过同样的教程。

Make sure your app is listed in notification center, and it's alert type is anything but not none.

确保您的应用程序在通知中心列出,它的警报类型是任何东西,但不是没有。

You need to check your notification in 3 conditions,

你需要在三个条件下检查你的通知,

When your app is open, in background, and when closed.

当你的应用程序打开时,在后台,当关闭时。

For that, you need to in check these methods

为此,需要检查这些方法

// To Register your device token
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken

//If your app is not able to register
- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{}

//Your app receives push notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{

    UIApplicationState state = [application applicationState];

    // If your app is running
    if (state == UIApplicationStateActive)
    {

        //You need to customize your alert by yourself for this situation. For ex,
        NSString *cancelTitle = @"Close";
        NSString *showTitle = @"Get Photos";
        NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@""
                                                            message:message
                                                           delegate:self
                                                  cancelButtonTitle:cancelTitle
                                                  otherButtonTitles:showTitle, nil];
        [alertView show];
        [alertView release];

    }
    // If your app was in in active state
    else if (state == UIApplicationStateInactive)
    {
    }
}

#4


1  

Please check in your device's Settings if notifications for the application are on and ensure that the type of the notification is not 'None' in Notification Center.

如果应用程序的通知是打开的,请检查设备的设置,并确保通知中心中的通知类型不是“None”。

#5


1  

Make sure, that you select right provision profile 在iPhone中没有收到任何推送通知

确保您选择了正确的供应概要文件

and that your app is minimized. If app's not minimized use

你的应用被最小化了。如果应用程序没有最小化使用

 - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    NSLog(@"info %@", userInfo);
}

Other useful information about issues.

关于问题的其他有用信息。

For TESTING pushes you can use APN Tester Free. Attention: insert token WITH spaces.

对于测试推送,您可以使用无APN测试器。注意:使用空格插入令牌。

#6


0  

I was not getting anything in:

我什么都没进:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any])

But my compiler stopped on breakpoint in

但是我的编译器在断点为

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)