add isAppInBackground to determine whether should notify user.
fix some common macro