Not receiving any push notification in iPhone

44,752

Solution 1

You will not receive Push only in 2 cases

1.) If your application is in foreground.

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

Solution 2

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

Solution 3

BE AWARE OF THE BATTERY ISSUE, WHICH BLOCKS YOU FOR ONE DAY OR MORE

Never start testing pushes in development mode (tethered phone) unless the phone is FULLY CHARGED.

https://developer.apple.com/library/archive/technotes/tn2265/_index.html

If your notification payload contains the content-available key, your app will receive the notification if iOS or OS X determines it is energy-efficient to do so. If the energy or data budget for the device has been exceeded, your app will not receive any more notifications with the content-available key until the budget has been reset. This occurs once a day and cannot be changed by user or developer action.

In general, notifications (particularly when you are tethered) are incredibly flakey regarding battery state of the phone. (Also, some of the stuff mentioned in that article, which is very old, is plain wrong.) Basically you often JUST WILL NEVER GET notifications if your phones enter "don't get notifications because of battery" mode - and it can go on for days.

Notifications do (or did) prefer cellular WTF!!!

On iOS, push notifications use the cellular data network whenever possible, even if the device is currently using Wi-Fi for other network activity such as web browsing or email. However, the push service will fall back to Wi-Fi if cellular data service isn't available.

This has changed a lot with different iOS versions but it's a huge hassle.

>>>>> !!! CRITICAL TIP !!! <<<<<

Don't forget that:

  1. Build to a tethered phone. You will only get the "sandbox, development" push notifications. BUT THOSE BARELY WORK - THEY ARRIVE VERY LATE, DO NOT WORK IN SOME REGIONS, AND SO ON. THEY ARE SO FLAKEY THEY ARE USUALLY NOT WORTH TRYING.

  2. Increase build number, build normally for Test Flight, send to test flight, and then install from Test Flight. You will now get CORRECT, NORMAL APPLE PUSH NOTIFICATIONS.

Very confusingly you !!DO!! get REAL push notifications on development Test Flight builds.

That is to say - when you build to TestFlight you DO GET exactly the same "real" push notifications as for actual apps published on the app store and used by your public users - real, true, APNS push notifications.

The incredibly confusingly-named "development, sandbox" push notifications are ONLY for "tethered phone builds". (AND, to add confusion on confusion, the "development, sandbox" push notifications are very unreliable, so you never really know if they are working or not.)

Read more here! https://stackoverflow.com/a/60550859/294884

Solution 4

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)
    {
    }
}

Solution 5

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.

Share:
44,752

Related videos on Youtube

Idiot
Author by

Idiot

Updated on July 16, 2020

Comments

  • Idiot
    Idiot almost 4 years

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

    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.

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

    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.

  • Saqib Saud
    Saqib Saud about 11 years
    are you using same certificate to generate SSL and provisioning profile? it they are not the same push notification wont work. Also verify if you successfully connect to APNS developer.apple.com/library/ios/#DOCUMENTATION/…
  • Idiot
    Idiot about 11 years
    saqib: I am able to run the app and its sure using APNS profile and also getting the Device Token in didRegisterForRemoteNotificationsWithDeviceToken method. i got the alert 'PushTest' would like to send you PusNotification' one time only, so its sure that I am using right profile.
  • Saqib Saud
    Saqib Saud about 11 years
    im sure you are using pushnotification enabled profile. But you might not be using the same CSR on client side and server side. which is usually the reason for pushnotification to not work.
  • Idiot
    Idiot about 11 years
    Thanks saqib....can u suggest me how can i verify the same(you might not be using the same CSR on client side and server side)
  • Idiot
    Idiot about 11 years
    I have already tried it with Banner & Alert. The app is being listed in NotificationCeter.
  • Idiot
    Idiot about 11 years
    Hi Hinta, the method - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo is not being called in my case. and all the others things are correct.
  • Baby Groot
    Baby Groot about 11 years
    I guess, you must have hardcoded your device token in simplePush.php. So there is no issue of registering your device. Now try to figure out why are you not receiving push notification at device end.
  • Idiot
    Idiot about 11 years
    Tons of Thanks Hinta...i figure it out,there was space in device token.
  • Roman
    Roman about 10 years
    just spent >1hr with my App in foreground trying to realize why I'm not receiving push notifications... oh damn!!! :)))
  • Divyam shukla
    Divyam shukla almost 9 years
    @Nitin are you using development certificate and provisioning profile and for creating ipa ?
  • Divyam shukla
    Divyam shukla almost 9 years
    You might choosing different certificate and provisioning profile for release and development mode.
  • Nitin
    Nitin almost 9 years
    i am using development certificates.. and development provisioning profiles. but in app id i have enabled development push notifications. i have followed Ray wenderlych tutorials... i have created ipa file in both ways. in development and in distribution. in distribution i have created production certificates and created ad hoc provisioning profiles but still didnt get my notifications working.. for the time my notifications are working.
  • Divyam shukla
    Divyam shukla almost 9 years
    @Nitin have you used the same certificate .pem file at the server end ?
  • Nitin
    Nitin almost 9 years
    yeah its same. i have deleted all info from server and from my keychain.. then created all. but still same issue dun know whats the issue.. right now notifications are working when i pick .app file from my bundle.
  • Anilkumar iOS - ReactNative
    Anilkumar iOS - ReactNative almost 9 years
    but, my application is close, i am not getting APNS. If my app is in background im getting APNS. any solutions for this?
  • Divyam shukla
    Divyam shukla almost 9 years
    @Anilkumar The device token might be cleared from the server side there must be some session concept in your app
  • Anilkumar iOS - ReactNative
    Anilkumar iOS - ReactNative almost 9 years
    we, figured out, its issue due to silent mode of APNS. Thanks for your response @Divz
  • Hemang
    Hemang over 8 years
    @Anilkumar, what kind of issue it was?
  • Hemang
    Hemang over 8 years
    @Divz, push notification is the magnificent issue with me, I received it throughly or stop receiving it suddenly. What to do for this case? Btw, I'm running an iOS app with In House provision profile. Everything is setup properly and can be working without making any kind of change.
  • Jayprakash Dubey
    Jayprakash Dubey almost 8 years
    @Divyamshukla : You saved my another day! I was struggling where I'm going wrong in code!
  • Divyam shukla
    Divyam shukla almost 8 years
    @JayprakashDubey :)
  • Vikas
    Vikas almost 7 years
    i recieived notificatuion on cansole but not display in notification view. So please give me solution
  • Divyam shukla
    Divyam shukla almost 7 years
    is your application is on forground ? @VikasDhasal
  • Divyam shukla
    Divyam shukla almost 7 years
    @VikasDhasal press home button when you will receive push it will be shown
  • Divyam shukla
    Divyam shukla almost 7 years
    your payload may be blank values you can get from userInfo.
  • MinnuKaAnae
    MinnuKaAnae over 5 years
    After spending 2hours time I found this solution, my app is in foreground thats why notifications are not received.
  • Divyam shukla
    Divyam shukla over 5 years
    @MinnuKaAnae enjoy :)
  • Vineesh TP
    Vineesh TP over 5 years
    ' APN Tester Free' Not available in India