没有收到推送通知请求

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

I am very new to this development, so please help me

我对这个发展很陌生,所以请帮助我

I am starting push notification using this code

我正在使用这段代码启动推送通知

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

But, on my device I am not getting push notification user permission alert saying "App Name" Would like to send Notifications

但是,在我的设备上,我没有收到推送通知用户权限警告,说“应用程序名称”想要发送通知

I found that if device is jail broken, then we don't receive permission alert message, but my device is not jail broken.

我发现如果设备坏了,我们不会收到许可警告信息,但是我的设备没有坏。

edited

编辑

I am also getting push notifications on my device, just not getting permission alert on first start.

我也在我的设备上收到推送通知,只是在第一次启动时没有收到许可警报。

Any help on this will be really thankful.

在这方面的任何帮助都将是非常感谢的。

4 个解决方案

#1


13  

from: https://developer.apple.com/library/ios/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG42

来自:https://developer.apple.com/library/ios/technotes/tn2265/_index.html # / / apple_ref / doc / uid / DTS40010376-CH1-TNTAG42

  1. Delete your app from the device.
  2. 从设备中删除应用程序。
  3. Turn the device off completely and turn it back on.
  4. 把设备完全关掉,再打开。
  5. Go to Settings > General > Date & Time and set the date ahead a day or more.
  6. 进入设置>一般>日期和时间,并将日期提前一天或更多。
  7. Turn the device off completely again and turn it back on.

    再次完全关闭设备并重新打开。

  8. Re-install the app

    重新安装应用程序

I just tested on iOS 7.1 and it worked. note this requires turning off the device TWICE.

我刚刚在ios7.1上测试过它。注意,这需要关闭设备两次。

#2


10  

I found that push notifications permission alert comes only first time application is started, even if we delete application, permission alert will not come. Even if application is uninstalled for more than 7 days, still permission alert will not come.

我发现推送通知权限警报只出现在第一次应用程序启动时,即使我们删除了应用程序,权限警报也不会出现。即使应用程序被卸载超过7天,仍然不会发出权限警告。

When I tested my application on different devices, I found this issue, that permission alert comes only once, first time application run.

当我在不同的设备上测试我的应用程序时,我发现了这个问题,权限警报只出现一次,第一次运行应用程序。

Hope this information helps others who also faced same issue..

希望这些信息能帮助同样面临同样问题的人。

#3


5  

if you use IOS S.1 /5.1 + , please read push notification Guidelines App Store Review Guidelines

如果你使用IOS。1 /5.1 +,请阅读推送通知指南应用商店评论指南。

By Apple Document

由苹果公司文档

The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.

第一次push-enabled应用注册推送通知,iOS询问用户是否希望接收通知的应用程序,一旦用户回应这个警报是不会再提出,除非设备恢复或应用程序卸载了至少一天。

If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by setting the system clock forward a day or more, turning the device off completely, then turning the device back on.

如果你想模拟你的应用程序第一次运行,你可以让应用程序卸载一天。通过将系统时钟向前调一天或更久,完全关闭设备,然后重新打开设备,您可以实现后者,而无需实际等待一天。

#4


0  

you need to do something like this- you need to register you device also.

你需要做这样的事情——你需要注册你的设备。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   

    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}

Notification delegate method callback as per your status-

通知委托方法回调按您的状态-。

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken 
{

}


- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err 
{
    DebugLog(@"Error in registration. Error: %@", err);
}

#1


13  

from: https://developer.apple.com/library/ios/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG42

来自:https://developer.apple.com/library/ios/technotes/tn2265/_index.html # / / apple_ref / doc / uid / DTS40010376-CH1-TNTAG42

  1. Delete your app from the device.
  2. 从设备中删除应用程序。
  3. Turn the device off completely and turn it back on.
  4. 把设备完全关掉,再打开。
  5. Go to Settings > General > Date & Time and set the date ahead a day or more.
  6. 进入设置>一般>日期和时间,并将日期提前一天或更多。
  7. Turn the device off completely again and turn it back on.

    再次完全关闭设备并重新打开。

  8. Re-install the app

    重新安装应用程序

I just tested on iOS 7.1 and it worked. note this requires turning off the device TWICE.

我刚刚在ios7.1上测试过它。注意,这需要关闭设备两次。

#2


10  

I found that push notifications permission alert comes only first time application is started, even if we delete application, permission alert will not come. Even if application is uninstalled for more than 7 days, still permission alert will not come.

我发现推送通知权限警报只出现在第一次应用程序启动时,即使我们删除了应用程序,权限警报也不会出现。即使应用程序被卸载超过7天,仍然不会发出权限警告。

When I tested my application on different devices, I found this issue, that permission alert comes only once, first time application run.

当我在不同的设备上测试我的应用程序时,我发现了这个问题,权限警报只出现一次,第一次运行应用程序。

Hope this information helps others who also faced same issue..

希望这些信息能帮助同样面临同样问题的人。

#3


5  

if you use IOS S.1 /5.1 + , please read push notification Guidelines App Store Review Guidelines

如果你使用IOS。1 /5.1 +,请阅读推送通知指南应用商店评论指南。

By Apple Document

由苹果公司文档

The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.

第一次push-enabled应用注册推送通知,iOS询问用户是否希望接收通知的应用程序,一旦用户回应这个警报是不会再提出,除非设备恢复或应用程序卸载了至少一天。

If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by setting the system clock forward a day or more, turning the device off completely, then turning the device back on.

如果你想模拟你的应用程序第一次运行,你可以让应用程序卸载一天。通过将系统时钟向前调一天或更久,完全关闭设备,然后重新打开设备,您可以实现后者,而无需实际等待一天。

#4


0  

you need to do something like this- you need to register you device also.

你需要做这样的事情——你需要注册你的设备。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   

    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}

Notification delegate method callback as per your status-

通知委托方法回调按您的状态-。

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken 
{

}


- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err 
{
    DebugLog(@"Error in registration. Error: %@", err);
}