Skip to content

Commit 48e0910

Browse files
authored
Alters FCM readme to refer directly to permanent docs.
1 parent d3e92f6 commit 48e0910

File tree

1 file changed

+26
-219
lines changed

1 file changed

+26
-219
lines changed

messaging/testapp/readme.md

Lines changed: 26 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -1,241 +1,48 @@
11
Firebase Cloud Messaging Quickstart
22
===================================
33

4-
The Firebase Cloud Messaging Test Application (testapp) demonstrates receiving
5-
Firebase Cloud Messages using the Firebase Cloud Messaging C++ SDK. This
4+
The Firebase Messaging C++ Sample (hereafter the 'test app') demonstrates receiving messages from [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/)
5+
using the [Firebase C++ SDK](https://firebase.google.com/docs/cpp/setup). This
66
application has no user interface and simply logs actions it's performing to the
77
console.
88

9-
Introduction
10-
------------
9+
## Set up, build and run the test app
1110

12-
- [Read more about Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/)
11+
> **_NOTE:_** Do not implement the code changes of the subsequent linked instructions as this codebase already has those functionalities.
1312
14-
Building and Running the testapp
15-
--------------------------------
16-
### iOS
17-
- Link your iOS app to the Firebase libraries.
18-
- Get CocoaPods version 1 or later by running,
13+
1. Complete [Add Firebase to your C++ project](https://firebase.google.com/docs/cpp/setup) for your selected build platforms.
14+
1. [Set up a Firebase Cloud Messaging client app with C++](https://firebase.google.com/docs/cloud-messaging/cpp/client).
1915

20-
```
21-
sudo gem install cocoapods --pre
22-
```
23-
- From the testapp directory, install the CocoaPods listed in the Podfile by
24-
running,
25-
```
26-
pod install
27-
```
28-
- Open the generated Xcode workspace (which now has the CocoaPods),
29-
30-
```
31-
open testapp.xcworkspace
32-
```
33-
- For further details please refer to the
34-
[general instructions for setting up an iOS app with Firebase](https://firebase.google.com/docs/ios/setup).
35-
36-
- Register your iOS app with Firebase.
37-
- Create a new app on
38-
[firebase.google.com/console](https://firebase.google.com/console/)
39-
, and attach your iOS app to it.
40-
- For Messaging, you will need an App Store ID. Use something random such
41-
as 12345678."
42-
- You can use "com.google.FirebaseCppMessagingTestApp.dev" as the iOS Bundle ID
43-
while you're testing.
44-
- Add the GoogleService-Info.plist that you downloaded from Firebase
45-
console to the testapp root directory. This file identifies your iOS app
46-
to the Firebase backend.
47-
- Download the Firebase C++ SDK linked from
48-
[https://firebase.google.com/docs/cpp/setup](https://firebase.google.com/docs/cpp/setup)
49-
and unzip it to a directory of your choice.
50-
- Add the following frameworks from the Firebase C++ SDK to the project:
51-
- frameworks/ios/universal/firebase.framework
52-
- frameworks/ios/universal/firebase_messaging.framework
53-
- You will need to either,
54-
1. Check "Copy items if needed" when adding the frameworks, or
55-
2. Add the framework path in "Framework Search Paths"
56-
- e.g. If you downloaded the Firebase C++ SDK to
57-
`/Users/me/firebase_cpp_sdk`,
58-
then you would add the path
59-
`/Users/me/firebase_cpp_sdk/frameworks/ios/universal`.
60-
- To add the path, in XCode, select your project in the project
61-
navigator, then select your target in the main window.
62-
Select the "Build Settings" tab, and click "All" to see all
63-
the build settings. Scroll down to "Search Paths", and add
64-
your path to "Framework Search Paths".
65-
- You need a valid
66-
[APNs](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html)
67-
certificate. If you don't already have one, see
68-
[Provisioning APNs SSL Certificates.](https://firebase.google.com/docs/cloud-messaging/ios/certs)
69-
- Configure the Xcode project for push messaging.
70-
- Select the `testapp` project from the `Navigator area`.
71-
- Select the `testapp` target from the `Editor area`.
72-
- Select the `General` tab from the `Editor area`.
73-
- Scroll down to `Linked Frameworks and Libraries` and click the `+`
74-
button to add a framework.
75-
- In the window that appears, scroll to `UserNotifications.framework`
76-
and click on that entry, then click on `Add`. This framework will only
77-
appear in Xcode version 8 and higher, required by this library.
78-
- Select the `Capabilities` tab from the `Editor area`.
79-
- Switch `Push Notifications` to `On`.
80-
- Scroll down to `Background Modes` and switch it to `On`.
81-
- Tick the `Remote notifications` box under `Background Modes`.
82-
- In XCode, build & run the sample on an iOS device or simulator.
83-
- The testapp has no user interface. The output of the app can be viewed
84-
via the console. In Xcode, select
85-
`View --> Debug Area --> Activate Console` from the menu.
86-
87-
### Android
88-
**Register your Android app with Firebase.**
89-
90-
- Create a new app on
91-
[firebase.google.com/console](https://firebase.google.com/console/)
92-
, and attach your Android app to it.
93-
- You can use "com.google.android.messaging.testapp" as the Package Name
94-
while you're testing.
95-
- To [generate a SHA1](https://developers.google.com/android/guides/client-auth)
96-
run this command (_Note: the default password is 'android'_):
97-
* Mac and Linux:
98-
99-
```
100-
keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
101-
```
102-
* Windows:
103-
104-
```
105-
keytool -exportcert -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
106-
```
107-
- If keytool reports that you do not have a debug.keystore, you can
108-
[create one](http://developer.android.com/tools/publishing/app-signing.html#signing-manually)
109-
with:
110-
111-
```
112-
keytool -genkey -v -keystore ~/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"
113-
```
114-
- Add the `google-services.json` file that you downloaded from Firebase
115-
console to the root directory of testapp. This file identifies your
116-
Android app to the Firebase backend.
117-
- For further details please refer to the
118-
[general instructions for setting up an Android app with Firebase](https://firebase.google.com/docs/android/setup).
119-
120-
- Download the Firebase C++ SDK linked from
121-
[https://firebase.google.com/docs/cpp/setup](https://firebase.google.com/docs/cpp/setup)
122-
and unzip it to a directory of your choice.
123-
124-
**Configure your SDK paths**
125-
126-
- Configure the location of the Firebase C++ SDK by setting the
127-
`firebase_cpp_sdk.dir` Gradle property to the SDK install directory.
128-
* Run this command in the project directory, and modify the path to match your
129-
local installation path:
130-
131-
```
132-
echo "systemProp.firebase_cpp_sdk.dir=/User/$USER/firebase_cpp_sdk" >> gradle.properties
133-
```
134-
- Ensure the Android SDK and NDK locations are set in Android Studio.
135-
* From the Android Studio launch menu, go to `File/Project Structure...` or
136-
`Configure/Project Defaults/Project Structure...`
137-
(Shortcut: Control + Alt + Shift + S on windows, Command + ";" on a mac)
138-
and download the SDK and NDK if the locations are not yet set.
139-
* Android Studio will write these paths to `local.properties`.
140-
141-
**Optional: Configure your deep link URL**
142-
143-
- To enable your app to receive deep links via FCM, you will need to add an
144-
intent filter to your AndroidManifest.xml in the native activity that
145-
associates your domain with your app.
146-
147-
```
148-
<intent-filter>
149-
<action android:name="android.intent.action.VIEW"/>
150-
<category android:name="android.intent.category.DEFAULT"/>
151-
<category android:name="android.intent.category.BROWSABLE"/>
152-
<data android:host="your-domain-here.example.com" android:scheme="http"/>
153-
<data android:host="your-domain-here.example.com" android:scheme="https"/>
154-
</intent-filter>
155-
```
156-
157-
**Build & Run**
158-
159-
- Open `build.gradle` in Android Studio.
160-
- From the Android Studio launch menu, "Open an existing Android Studio
161-
project", and select `build.gradle`.
162-
- Install the SDK Platforms that Android Studio reports missing.
163-
- Build the testapp and run it on an Android device or emulator.
164-
- See [below](#using_the_test_app) for usage instructions.
165-
166-
### Desktop
167-
- Register your app with Firebase.
168-
- Create a new app on the [Firebase console](https://firebase.google.com/console/),
169-
following the above instructions for Android or iOS.
170-
- If you have an Android project, add the `google-services.json` file that
171-
you downloaded from the Firebase console to the root directory of the
172-
testapp.
173-
- If you have an iOS project, and don't wish to use an Android project,
174-
you can use the Python script `generate_xml_from_google_services_json.py --plist`,
175-
located in the Firebase C++ SDK, to convert your `GoogleService-Info.plist`
176-
file into a `google-services-desktop.json` file, which can then be
177-
placed in the root directory of the testapp.
178-
- Download the Firebase C++ SDK linked from
179-
[https://firebase.google.com/docs/cpp/setup](https://firebase.google.com/docs/cpp/setup)
180-
and unzip it to a directory of your choice.
181-
- Configure the testapp with the location of the Firebase C++ SDK.
182-
This can be done a couple different ways (in highest to lowest priority):
183-
- When invoking cmake, pass in the location with
184-
-DFIREBASE_CPP_SDK_DIR=/path/to/firebase_cpp_sdk.
185-
- Set an environment variable for FIREBASE_CPP_SDK_DIR to the path to use.
186-
- Edit the CMakeLists.txt file, changing the FIREBASE_CPP_SDK_DIR path
187-
to the appropriate location.
188-
- From the testapp directory, generate the build files by running,
189-
```
190-
cmake .
191-
```
192-
If you want to use XCode, you can use -G"Xcode" to generate the project.
193-
Similarly, to use Visual Studio, -G"Visual Studio 15 2017". For more
194-
information, see
195-
[CMake generators](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html).
196-
- Build the testapp, by either opening the generated project file based on
197-
the platform, or running,
198-
```
199-
cmake --build .
200-
```
201-
- Execute the testapp by running,
202-
```
203-
./desktop_testapp
204-
```
205-
Note that the executable might be under another directory, such as Debug.
206-
- The testapp has no user interface, but the output can be viewed via the
207-
console. Note that Messaging uses a stubbed implementation on desktop,
208-
so functionality is not expected.
209-
210-
Using the Test App
211-
------------------
16+
### Running the test app
17+
----------------------
21218

21319
- Install and run the test app on your iOS or Android device or emulator.
21420
- The application has minimal user interface. The output of the app can be
21521
viewed via the console:
216-
* **iOS**: Open select "View --> Debug Area --> Activate Console" from the
22+
* **iOS**: Open select "View -> Debug Area -> Activate Console" from the
21723
menu in Xcode.
21824
* **Android**: View the logcat output in Android studio or by running
219-
"adb logcat" from the command line.
25+
`adb logcat` from the command line.
22026
- When you first run the app, it will print:
22127
`Received Registration Token: <code>`. Copy this code to a text editor.
222-
- Copy the ServerKey from the firebase console:
223-
- Open your project in the
224-
[Firebase Console](https://firebase.google.com/console/).
225-
- Click the gear icon then `Project settings` in the menu on the left
226-
- Select the `Cloud Messaging` tab.
227-
- Copy the `Server Key`
228-
- Replace `<Server Key>` and `<Registration Token>` in this command and run it
229-
from the command line.
230-
```
231-
curl --header "Authorization: key=<Server Key>" --header "Content-Type: application/json" https://android.googleapis.com/gcm/send -d '{"notification":{"title":"Hi","body":"Hello from the Cloud"},"data":{"score":"lots"},"to":"<Registration Token>"}'
232-
```
233-
- Observe the command received in the app, via the console output.
23428

235-
Support
236-
-------
29+
### Send a message from your server environment
30+
-----------------------------------------------
31+
32+
1. Navigate to the FCM REST API Docs for [Method: projects.messages.send](https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send)
33+
1. Look for the "Try this method" panel
34+
1. This might require you to expand your browser window.
35+
1. Follow the API doc to understand what IDs and fields to fill in for your particular use case.
36+
1. Your project number is available from [Project settings](https://console.firebase.google.com/project/_/settings/general)
37+
1. Fill in the `Request body` referencing the [FCM REST API docs](https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages).
38+
1. Execute.
39+
1. Observe the command received in the app, via the console output.
40+
41+
Reminder, while this process is currently done from our website, it uses the FCM v1 Send API directly and provides the simplest starting point to switch to using the Send API or Admin SDKs in production.
23742

238-
[https://firebase.google.com/support/](https://firebase.google.com/support/)
43+
## Troubleshooting and Support
44+
- [Firebase Cloud Messaging troubleshooting & FAQ](https://firebase.google.com/docs/cloud-messaging/troubleshooting)
45+
- [Firebase Support](https://firebase.google.com/support/)
23946

24047
License
24148
-------

0 commit comments

Comments
 (0)