Skip to content

Instantly share code, notes, and snippets.

@brickpop
Last active February 1, 2017 23:48

Revisions

  1. Jordi Moraleda revised this gist Feb 1, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions fcm-ios-react-native.txt
    Original file line number Diff line number Diff line change
    @@ -70,6 +70,7 @@ Select your project name Scheme then click on the minus sign ― in the bottom l
    Twins scheme > Build >
    - Uncheck "Parallelize Builds"
    - Add "React" and put it first
    - Uncheck Analyze in Twins and React

    # https://twitter.com/skellock/status/818813810781908992

  2. Jordi Moraleda revised this gist Feb 1, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions fcm-ios-react-native.txt
    Original file line number Diff line number Diff line change
    @@ -67,6 +67,12 @@ Select your project Capabilities and enable Keychan Sharing and Background Modes
    In Xcode menu bar, select Product > Scheme > Manage schemes.
    Select your project name Scheme then click on the minus sign ― in the bottom left corner, then click on the plus sign + and rebuild your project scheme.

    Twins scheme > Build >
    - Uncheck "Parallelize Builds"
    - Add "React" and put it first

    # https://twitter.com/skellock/status/818813810781908992

    ----

    - Inside your project in the Firebase console, select the gear icon, select Project Settings, and then select the Cloud Messaging tab.
  3. Jordi Moraleda revised this gist Feb 1, 2017. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions fcm-ios-react-native.txt
    Original file line number Diff line number Diff line change
    @@ -60,11 +60,12 @@ AppDelegats.m (update)
    }

    ----
    XCode

    Select your project Capabilities and enable Keychan Sharing and Background Modes > Remote notifications.

    In Xcode menu bar, select Product > Scheme > Manage schemes. Select your project name Scheme then click on the minus sign ― in the bottom left corner, then click on the plus sign + and rebuild your project scheme.

    In Xcode menu bar, select Product > Scheme > Manage schemes.
    Select your project name Scheme then click on the minus sign ― in the bottom left corner, then click on the plus sign + and rebuild your project scheme.

    ----

  4. Jordi Moraleda revised this gist Feb 1, 2017. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions fcm-ios-react-native.txt
    Original file line number Diff line number Diff line change
    @@ -71,3 +71,7 @@ In Xcode menu bar, select Product > Scheme > Manage schemes. Select your project
    - Inside your project in the Firebase console, select the gear icon, select Project Settings, and then select the Cloud Messaging tab.
    - Select the Upload Certificate button for your development certificate, your production certificate, or both. At least one is required.
    - For each certificate, select the .p12 file, and provide the password, if any. Make sure the bundle ID for this certificate matches the bundle ID of your app. Select Save.

    ----


  5. Jordi Moraleda revised this gist Feb 1, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions fcm-ios-react-native.txt
    Original file line number Diff line number Diff line change
    @@ -65,3 +65,9 @@ Select your project Capabilities and enable Keychan Sharing and Background Modes

    In Xcode menu bar, select Product > Scheme > Manage schemes. Select your project name Scheme then click on the minus sign ― in the bottom left corner, then click on the plus sign + and rebuild your project scheme.


    ----

    - Inside your project in the Firebase console, select the gear icon, select Project Settings, and then select the Cloud Messaging tab.
    - Select the Upload Certificate button for your development certificate, your production certificate, or both. At least one is required.
    - For each certificate, select the .p12 file, and provide the password, if any. Make sure the bundle ID for this certificate matches the bundle ID of your app. Select Save.
  6. Jordi Moraleda revised this gist Feb 1, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions fcm-ios-react-native.txt
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    # Extra info:
    # https://firebase.google.com/docs/ios/setup

    react-native init Twins
    cd Twins

  7. Jordi Moraleda renamed this gist Feb 1, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. Jordi Moraleda created this gist Feb 1, 2017.
    64 changes: 64 additions & 0 deletions info.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,64 @@
    react-native init Twins
    cd Twins

    react-native run-ios

    yarn add react-native-fcm
    react-native link react-native-fcm

    cd ios
    pod init

    Add the following line inside the Podfile
    >> pod 'Firebase/Messaging'

    pod install


    open ios/Twins.xcworkspace
    Build Settings > Header search path > add:
    >> '$(SRCROOT)/../node_modules/react-native-fcm/ios'

    AppDelegate.h (update)
    @import UserNotifications;

    @interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate>

    AppDelegats.m (update)
    #import "RNFIRMessaging.h"

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    //...

    [FIRApp configure];
    [[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];

    // ...
    }

    - (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
    {
    [RNFIRMessaging willPresentNotification:notification withCompletionHandler:completionHandler];
    }

    - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler
    {
    [RNFIRMessaging didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
    }

    //You can skip this method if you don't want to use local notification
    -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
    [RNFIRMessaging didReceiveLocalNotification:notification];
    }

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
    [RNFIRMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
    }

    ----

    Select your project Capabilities and enable Keychan Sharing and Background Modes > Remote notifications.

    In Xcode menu bar, select Product > Scheme > Manage schemes. Select your project name Scheme then click on the minus sign ― in the bottom left corner, then click on the plus sign + and rebuild your project scheme.