This page (revision-1) was last changed on 20-Apr-2024 11:53 by Hiroaki Tateshita

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
20-Apr-2024 11:53 3 KB Hiroaki Tateshita

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 1 added 66 lines
[{PageViewPlugin}]
[Emergency Situation Sharing Tool], [Send Message by Gmail], [Cloud Functions], [Firebase Cloud Messaging], [Google Assistant API]
!!!Abstract
I'm thinking what I wanted to do in ESST project can be implemented by using Firebase. I would like to study how Firebase can work by trying to develop ESST by using Firebase.
!!!Topics
*[Android]クライアントからTwitterのタイムラインを取得できるか?
|Firebaseのドキュメント[1]をベースに進めてみよう。
|Twitter APIに登録して、API KeyとAPI Secretを取得して、FirebaseのAuthentificationのTwitterを有効にしてみた。
{{{Default FirebaseApp is not initialized in this process Make sure to call FirebaseApp.initializeApp(Context) first.
FirebaseAuth.getInstance();}}}
|これが出て先に進めない。
|ここ[2]も重要だ。これをちゃんとやってみよう。
|いつの間にか、上記エラーも出なくなるが、コンパイルエラーが。。。
{{{
Invoke-customs are only supported starting with Android O (--min-api 26)
Message{kind=ERROR, text=Invoke-customs are only supported starting with Android O (--min-api 26), sources=[Unknown source file], tool name=Optional.of(D8)}
}}}
|うーん、以下をProjectのbuild.gradleに追加して解決[5]。
{{{
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}}}
|TimeLineは取得できるようになりました。
*quick start sample
|行き詰ったので、まずは、[Android]のクイックスタートをやってみる[3]。githubからプロジェクトフォルダダウンロードして、展開して、[Android Studio]でauthフォルダを開く。そうすると、必要なダウンロードが自動的に始まる。
|エラーがいくつかでて終わる。必要な設定ファイルがないから当然。Tool->Firebaseでアシスト画面を開きAuthentification->connect Firebaseをやると、ネットワークの調子が良ければ、Firebaseサーバ側にプロジェクトが生成され、Androidアプリ側にもgoogle-services.jsonなど必要なファイルがダウンロードされて設定ができる。
|TwitterのAPI KeyやAPI SecretをAPPSページ[4]から持ってきて、Firebase Consoleのページと[Android]のリソースresにあるids.xmlに追加。
{{{
com.google.firebase.FirebaseException: An internal error has occurred.
Identity Toolkit API has not been used in project 937695033468 before or it is disabled.
Enable it by visiting
https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=937695033468 then retry.
If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
}}}
|Identity Toolkit APIを有効にしてみる。
{{{
com.google.firebase.auth.FirebaseAuthException:
The given sign-in provider is disabled for this Firebase project.
Enable it in the Firebase console, under the sign-in method tab of the Auth section.
}}}
|注意点ですが、慣れていないと意外と引っかかるのが、[Android Studio]のConnect to Firebaseを使って設定すると、Firebase上にどんどんプロジェクトが自動作成されます。どのアプリがどのプロジェクトに接続するかを理解しながらAndroidアプリ側、Firebaseサーバ側、Twitterサーバ側を設定しないと当然エラーがおこります。当たり前なのですが。。
*AndroidクライアントからGmailが送れるか?
|まずは、OAuthでGoogleにログインしてみる。なお、[6]で最初に要求されるSHA Finger Printは、Firebase Assistantがすでに設定してくれてた.できたこと、できなかったことを[Send Message by Gmail]に記録。
*Firebaseのサーバ側のDBにクライアントからメッセージを登録できるか。
|Cloud [Firestore] がそれかもしれない。ちょっと試してみる。
*[Web Application on Firebase]
|アンドロイドだけじゃなく、ウェブもやってみる。
*リアルタイムでプッシュできるか?
|リアルタイムというのは[Cloud Functions]
|プッシュはサーバからクライアントにメッセージを送るもの。[Firebase Cloud Messaging]でサーバからクライアントはできる。クライアントからクライアントにおくるのは今回gmailでやるとして、Twitter からリアルタイムで情報を取得するのをできないものか。
!!!Reference
#[#1]Google, Android で Twitter を使用して認証する, [https://firebase.google.com/docs/auth/android/twitter-login?hl=ja]
#[#2]Google, Android プロジェクトに Firebase を追加する, [https://firebase.google.com/docs/android/setup?hl=ja]
#[#3]Google Inc, quickstart-android, [https://github.com/firebase/quickstart-android]
#[#4]Twitter, Inc., Twitter Apps, [https://apps.twitter.com]
#[#5]Invoke-customs are only supported starting with android 0 --min-api 26, [https://stackoverflow.com/questions/49891730/invoke-customs-are-only-supported-starting-with-android-0-min-api-26]
#[#6]Google Inc, Android で Google ログインを使用して認証する, [https://firebase.google.com/docs/auth/android/google-signin?hl=ja]