2016-06-24 12 views
5

kullanarak ios'da görüntülenmez; böylece, söz konusu uygulamada pod kullanarak pod kullanarak FCM'yi tümleştirmeye taşındık. burada öğretici içinde iyi karşılandı edilmişti ne uzak bildirim oluyor hem devlet Arkaplan Devlet ve aktif devlet ama bildirim burada bildirim çubuğunda görünmüyor edilir karşılaştığı temel sorun iuzaktan bildirimi, numaralı GCM bulut mesajlaşma sürümünün yükseltici sürümü olan FCM bulut mesajlarını dağıttıktan sonra FCM

kullanıyorum benim kodudur
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 



    float ver = [[[UIDevice currentDevice] systemVersion] floatValue]; 

    if(ver >= 8 && ver<9) 
    { 
     if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) 
     { 
      [[UIApplication sharedApplication] registerForRemoteNotifications]; 
      UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil]; 
      [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 

     } 
    }else if (ver >=9){ 

     [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; 

     [[UIApplication sharedApplication] registerForRemoteNotifications]; 


    } 
    else{ 
     //iOS6 and iOS7 specific code 
     [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeAlert]; 
    } 
    // ma tensa google maps 
    [FIRApp configure]; 
    [self connectToFcm]; 

} 


- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken { 

    NSLog(@"My token is: %@", deviceToken); 
} 

- (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error { 
    NSLog(@"Failed to get token, error: %@", error); 
} 
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { 


     UILocalNotification *localNotification = [[UILocalNotification alloc] init]; 
     localNotification.userInfo = userInfo; 
     localNotification.applicationIconBadgeNumber = 0; 
     localNotification.soundName = UILocalNotificationDefaultSoundName; 
     localNotification.fireDate = [NSDate date]; 
     [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 

    NSLog(@"Message ID: %@", userInfo[@"gcm.message_id"]); 


//  
// if (application.applicationState == active) { 
//  <#statements#> 
// } 
    // Pring full message. 
    NSLog(@"%@", userInfo); 
} 

- (void)applicationDidEnterBackground:(UIApplication *)application { 

    // [[FIRMessaging messaging] disconnect]; 


} 


- (void)connectToFcm { 
    [[FIRMessaging messaging] connectWithCompletion:^(NSError * _Nullable error) { 
     if (error != nil) { 
      NSLog(@"Unable to connect to FCM. %@", error); 
     } else { 
      NSLog(@"Connected to FCM."); 

       [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"registeredToFCM"]; 
       [[NSUserDefaults standardUserDefaults] synchronize]; 




    // i used the method since not all the time app register for fcm so when 
//the complete launching and did not register // 
//for fcm the app request to register fro fcm again// 

     } 
    }]; 
} 

Burada aradığım bağlantılardan bazıları Burada Notifications are not getting in iOS 9.2, FCM background notifications not working in iOS ve Push notifications are not working in iOS 9 geçmeden önce benim sorunu çözmek için ama

telefon zil ve bildirim alınmıştı zaman titreşiyor söylemeye unuttum sorunumu çözememiştir için ed.

herhangi bir yardım umuyoruz Happy Coding !!

+0

sidenote: haritalar unutmamak için, eklemek '#warning ma tensa google size basarak gönderiyor yük ne tür – Hussein

+0

maps'? İtme yükünün bir örneğini (JSON belki?) Verebilir misiniz? – Hussein

+0

fcm konsolundan –

cevap

0

Bildirimin görünmesini istiyorsanız, "öncelik" ayarını yapmanız gerekir: "yüksek". böylece gibi:

"to":"TOKEN ID", 
"notification" : { 
    "body" : "test" 
}, 
"priority": "high" 
}