私はiOSプログラマではありません。プッシュ通知を受け取ることはできますが、画面には2つのアラートが表示されます。IOS通知がデフォルトで2回表示され、通知通知が表示されます
問題1:私は の下に作成していUIAlertView* alertWindow
と -One - 第二には、デフォルトの通知アラートウィンドウのようです。 2番目のウィンドウを作成するときに間違っていることは何ですか?
問題2:デバイスがロックされていると、画面に通知が表示されますが、これはデフォルトの通知ウィンドウです。私はdidReceiveRemoteNotification
に入っている詳細の通知は表示されません。
if else
ブロックについて誰かがdidFinishLaunchingWithOptions
で説明できることをお詫び申し上げます。私はそれを貼り付けた。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *AMAZON_SERVER = @"xxxxxx";
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
configuration.applicationId = APPLICATION_ID;
configuration.clientKey = CLIENT_KEY;
configuration.server = AMAZON_SERVER;
}]];
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
[Fabric with:@[[Digits class]]];
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
}
else
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
if([[NSUserDefaults standardUserDefaults] boolForKey:@"FirstLaunch"]!=TRUE)
{
[[NSUserDefaults standardUserDefaults] setBool:FALSE forKey:@"FirstLaunch"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
//storedevice Type in standardUserDefaults
[self setDeviceType];
return YES;
}
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
[application registerForRemoteNotifications];
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSLog(@"Error in registration. Error: %@", err);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
if ([userInfo objectForKey:@"aps"]) {
NSMutableDictionary * apsData = [userInfo objectForKey:@"aps"];
NSString* alert = [apsData objectForKey:@"alert"];
...
...
UIAlertView* alertWindow = [[UIAlertView alloc] initWithTitle: alertHeader
message: message
delegate: self
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
[alertWindow show];
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
} else {
[PFPush handlePush:userInfo];
}
}
あなたは2回登録されています。問題が発生します –
それがアクティブであればそれを表示し、それ以外の場合はアラートを表示しないでください。 Active状態の通知バナーは表示されないためです。 –
@ HariKrishnan.P 2回登録した場所を教えてください。あなたは 'didReceiveRemoteNotification' – user1324887