How do I tell if my iPhone app is running when a Push Notification is received?

前端 未结 5 501
栀梦
栀梦 2020-12-04 14:39

I am sending Push Notifications to my iPhone app, and I\'d like a different set of instructions to execute depending on whether the app is already launched or not. I\'m new

5条回答
  •  长情又很酷
    2020-12-04 15:14

    If you are going to check applicationState on iOS less than 4, you'll need to check that applicationState is supported:

    if ([application respondsToSelector:@selector(applicationState)] ){
      // Safe to check applicationState
      UIApplicationState state = [application applicationState];
    }
    

提交回复
热议问题