开发者

How to know the app is invoked from background process or not

开发者 https://www.devze.com 2023-02-24 07:34 出处:网络
Thanks in advance. I used push notification service in my application.If the app is running in background i am able get the alert view, but the app is in active state it is not displaying alert. Is th

Thanks in advance.

I used push notification service in my application.If the app is running in background i am able get the alert view, but the app is in active state it is not displaying alert. Is there any way to display alert.

Actually to display alert i am creating an alert in - (void)application:(UIApplicati开发者_开发知识库on *)application didReceiveRemoteNotification:(NSDictionary *)userInfo method.

But there is a problam with this alert i.e., of the app is running in background we will get remote alert at the same time we will get this alert also.

So is there any way to find if the app is in active state or in background while receiving remote notification using didReceiveRemoteNotification method.


A simple solution I can think of is to make use of applicationDidBecomeActive: and applicationDidEnterBackground:. Declare a property in your app delegate and set it properly in those two methods. Then you can do anything you want based on this property, like [[[UIApplication sharedApplication] delegate] isInBackground].

0

精彩评论

暂无评论...
验证码 换一张
取 消