{"action":"created","issue":{"url":"https://api.github.com/repos/invertase/react-native-firebase/issues/1119","repository_url":"https://api.github.com/repos/invertase/react-native-firebase","labels_url":"https://api.github.com/repos/invertase/react-native-firebase/issues/1119/labels{/name}","comments_url":"https://api.github.com/repos/invertase/react-native-firebase/issues/1119/comments","events_url":"https://api.github.com/repos/invertase/react-native-firebase/issues/1119/events","html_url":"https://github.com/invertase/react-native-firebase/issues/1119","id":325158491,"number":1119,"title":"No Push Notification in iOS","user":{"login":"husnaingoldev","id":22097139,"avatar_url":"https://avatars3.githubusercontent.com/u/22097139?v=4","gravatar_id":"","url":"https://api.github.com/users/husnaingoldev","html_url":"https://github.com/husnaingoldev","followers_url":"https://api.github.com/users/husnaingoldev/followers","following_url":"https://api.github.com/users/husnaingoldev/following{/other_user}","gists_url":"https://api.github.com/users/husnaingoldev/gists{/gist_id}","starred_url":"https://api.github.com/users/husnaingoldev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/husnaingoldev/subscriptions","organizations_url":"https://api.github.com/users/husnaingoldev/orgs","repos_url":"https://api.github.com/users/husnaingoldev/repos","events_url":"https://api.github.com/users/husnaingoldev/events{/privacy}","received_events_url":"https://api.github.com/users/husnaingoldev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-05-22T06:37:17Z","updated_at":"2018-05-22T09:30:49Z","closed_at":null,"author_association":"NONE","body":"    import firebase from 'react-native-firebase';\r\n    import type, { RemoteMessage, Notification, NotificationOpen } from 'react-native-firebase';\r\n\r\n\r\n    import { Platform } from 'react-native';\r\n\r\n    export class MyPushNotification {\r\n\r\n    getInitialNotification = (navigate) => {\r\n\r\n\r\n            firebase.notifications().getInitialNotification()\r\n                .then((notificationOpen) => {\r\n                   \r\n                    if (notificationOpen) {\r\n\r\n                        console.log(\"initial notification\", notificationOpen);\r\n                        // App was opened by a notification\r\n                        // Get the action triggered by the notification being opened\r\n                        // const action = notificationOpen.action;\r\n                        // Get information about the notification that was opened\r\n                        // const notification = notificationOpen.notification;\r\n                        this.openThreadNow(notificationOpen, navigate);\r\n                    }\r\n                });\r\n        \r\n    }\r\n\r\n\r\n\r\n    onComponentDidMount = () => {\r\n\r\n            this.notificationListener = firebase.notifications().onNotification((notification) => {\r\n                // Process your notification as required\r\n                console.log(\"notification received\", notification);\r\n\r\n            });\r\n    }\r\n\r\n    onComponentWillMount = () => {\r\n\r\n            this.messageListener = firebase.messaging().onMessage((message) => {\r\n                // Process your message as required\r\n\r\n                console.log(\"message received\", message);\r\n            });\r\n    }\r\n\r\n\r\n\r\n    getToken = (is_push_enabled, server_type) => {\r\n\r\n            firebase.messaging().getToken().then(fcmToken => {\r\n                if (fcmToken) {\r\n                    console.log(\"fcmTokenfcmToken\", fcmToken);\r\n                    this.savePushTokenToServer(fcmToken, server_type);\r\n                } else {\r\n                    console.log(\"no token found\");\r\n                }\r\n            });\r\n    }\r\n\r\n\r\n    initPushService = (server_type, is_push_enabled, navigate) => {\r\n\r\n        this.my_navigator = navigate;\r\n        try {\r\n            firebase.messaging().requestPermission()\r\n                .then(() => {\r\n                    \r\n                    this.getToken(is_push_enabled, server_type);\r\n                })\r\n                .catch(error => {\r\n                    console.log(\"user rejected the permission\");\r\n                });\r\n        } catch (e) {\r\n            console.log(\"eeeeeeeee\", e);\r\n        }\r\n    }\r\n\r\n    }\r\n\r\n\r\nthis is my code for Push Notification Class, i am calling it from a class component like follwoing\r\n\r\n    push_service;\r\n\r\n    constructor(props) {\r\n        super(props);\r\n        this.push_service = new MyPushNotification();\r\n    }\r\n\r\n    componentWillMount() {\r\n\r\n        this.push_service.onComponentWillMount()\r\n\r\n    }\r\n\r\n\r\n    componentDidMount() {\r\n          this.push_service.initPushService(\"test1\", true, this.props.navigation);\r\n          this.push_service.onComponentDidMount();\r\n          this.push_service.getInitialNotification(this.props.navigation);\r\n\r\n    }\r\n\r\n\r\nand this is the code for AppDelegate.m\r\n\r\n\r\n    #import \"AppDelegate.h\"\r\n    #import <React/RCTBundleURLProvider.h>\r\n    #import <React/RCTRootView.h>\r\n\r\n    #import <Firebase.h>\r\n    #import \"RNFirebaseNotifications.h\"\r\n    #import \"RNFirebaseMessaging.h\"\r\n\r\n    @implementation AppDelegate\r\n\r\n    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary     *)launchOptions\r\n    {\r\n      [FIRApp configure];\r\n      NSURL *jsCodeLocation;\r\n  \r\n      jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@\"index\" fallbackResource:nil];\r\n  \r\n      RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation\r\n                                                      moduleName:@\"MyFirebase\"\r\n                                               initialProperties:nil\r\n                                                   launchOptions:launchOptions];\r\n      rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];\r\n  \r\n      self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];\r\n      UIViewController *rootViewController = [UIViewController new];\r\n      rootViewController.view = rootView;\r\n      self.window.rootViewController = rootViewController;\r\n      [self.window makeKeyAndVisible];\r\n  \r\n      [RNFirebaseNotifications configure];\r\n  \r\n      return YES;\r\n    }\r\n    - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {\r\n      [[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];\r\n    }\r\n\r\n    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo\r\n    fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{\r\n      [[RNFirebaseNotifications instance] didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];\r\n    }\r\n\r\n    - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {\r\n      [[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];\r\n    }\r\n\r\n    @end\r\n\r\n\r\nbackground remote notification works in android but not in iOS, i am testing on iOS 10.3.3\r\n\r\n\r\nif the app is in foreground whenever i send a new push notification from Firebase console, i see a console  with this line \r\n    console.log(\"message received\", message);\r\n\r\nand when app is killed or in background no notification appears in the notifications center, and if i open the app ty tapping the app icon, this same line executes again\r\n    console.log(\"message received\", message);\r\n\r\n\r\nPlease help in this issue, i am stuck in it for days."},"comment":{"url":"https://api.github.com/repos/invertase/react-native-firebase/issues/comments/390925711","html_url":"https://github.com/invertase/react-native-firebase/issues/1119#issuecomment-390925711","issue_url":"https://api.github.com/repos/invertase/react-native-firebase/issues/1119","id":390925711,"user":{"login":"cristianonescu","id":31920496,"avatar_url":"https://avatars3.githubusercontent.com/u/31920496?v=4","gravatar_id":"","url":"https://api.github.com/users/cristianonescu","html_url":"https://github.com/cristianonescu","followers_url":"https://api.github.com/users/cristianonescu/followers","following_url":"https://api.github.com/users/cristianonescu/following{/other_user}","gists_url":"https://api.github.com/users/cristianonescu/gists{/gist_id}","starred_url":"https://api.github.com/users/cristianonescu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cristianonescu/subscriptions","organizations_url":"https://api.github.com/users/cristianonescu/orgs","repos_url":"https://api.github.com/users/cristianonescu/repos","events_url":"https://api.github.com/users/cristianonescu/events{/privacy}","received_events_url":"https://api.github.com/users/cristianonescu/received_events","type":"User","site_admin":false},"created_at":"2018-05-22T09:30:49Z","updated_at":"2018-05-22T09:30:49Z","author_association":"NONE","body":"@husnaingoldev \r\n\r\nmy App.js looks now like this.. and nothing\r\n```\r\n/**\r\n * Sample React Native App\r\n * https://github.com/facebook/react-native\r\n * @flow\r\n */\r\n\r\nimport React, { Component } from 'react';\r\nimport {\r\n  Platform,\r\n  StyleSheet,\r\n  Text,\r\n  View,\r\n  TouchableOpacity\r\n} from 'react-native';\r\n\r\nimport firebase from 'react-native-firebase';\r\nimport type, { RemoteMessage, Notification, NotificationOpen } from 'react-native-firebase';\r\n\r\n\r\nconst instructions = Platform.select({\r\n  ios: 'Press Cmd+R to reload,\\n' +\r\n    'Cmd+D or shake for dev menu',\r\n  android: 'Double tap R on your keyboard to reload,\\n' +\r\n    'Shake or press menu button for dev menu',\r\n});\r\n\r\nconst notification = new firebase.notifications.Notification()\r\n  .setNotificationId('notificationId')\r\n  .setTitle('My notification title')\r\n  .setBody('My notification body')\r\n  .setData({\r\n    key1: 'value1',\r\n    key2: 'value2',\r\n  });\r\n\r\ntype Props = {};\r\nexport default class App extends Component<Props> {\r\n\r\n  componentWillUnmount() {\r\n    this.notificationDisplayedListener();\r\n    this.notificationListener();\r\n    this.notificationOpenedListener();\r\n  }\r\n\r\n  componentDidMount() {\r\n    this.notificationListener = firebase.notifications().onNotification((notification) => {\r\n      // Process your notification as required\r\n      console.log(\"notification received\", notification);\r\n    });\r\n\r\n\r\n    firebase.notifications().getInitialNotification()\r\n      .then((notificationOpen) => {\r\n        if (notificationOpen) {\r\n\r\n\r\n          // console.log(\"initial notification\", notificationOpen);\r\n          // App was opened by a notification\r\n          // Get the action triggered by the notification being opened\r\n          // const action = notificationOpen.action;\r\n          // Get information about the notification that was opened\r\n          // const notification = notificationOpen.notification;\r\n          this.openThreadNow(notificationOpen, navigate);\r\n        }\r\n      });\r\n  }\r\n\r\n  componentWillMount() {\r\n\r\n    this.messageListener = firebase.messaging().onMessage((message) => {\r\n\r\n      console.log(\"message received\", message);\r\n    });\r\n  }\r\n\r\n  render() {\r\n    return (\r\n      <View style={styles.container}>\r\n        <Text style={styles.welcome}>\r\n          Welcome to React Native!\r\n        </Text>\r\n        <TouchableOpacity\r\n          style={{ backgroundColor: 'cyan' }}\r\n          onPress={() => {\r\n          }}>\r\n          <Text>Test</Text>\r\n        </TouchableOpacity>\r\n        <Text style={styles.instructions}>\r\n          To get started, edit App.js\r\n        </Text>\r\n        <Text style={styles.instructions}>\r\n          {instructions}\r\n        </Text>\r\n      </View>\r\n    );\r\n  }\r\n}\r\n\r\nconst styles = StyleSheet.create({\r\n  container: {\r\n    flex: 1,\r\n    justifyContent: 'center',\r\n    alignItems: 'center',\r\n    backgroundColor: '#F5FCFF',\r\n  },\r\n  welcome: {\r\n    fontSize: 20,\r\n    textAlign: 'center',\r\n    margin: 10,\r\n  },\r\n  instructions: {\r\n    textAlign: 'center',\r\n    color: '#333333',\r\n    marginBottom: 5,\r\n  },\r\n});\r\n```"}}
{"actor":{"display_login":"cristianonescu"}}