아래는 제가 작성한 코드이구요
override fun onNewToken(token: String?) {
Log.d(TAG, "new Token: $token")
sendRegistrationToServer(token)
}
private fun sendRegistrationToServer(token: String?){
//데이터를 담아 보낼 바디생성
val body = FormBody.Builder()
.add("token", token)
.build()
//토큰을 보낼 링크를 지정해준다
val request = Request.Builder()
.url("http://www/fcm/resigster.php")
.post(body)
.build()
//클라이언트 생성
val client = OkHttpClient()
//요청 전송
try {
client.newCall(request).execute()
Log.d("요청","요청 완료")
}catch (e: IOException) {
e.printStackTrace()
Log.d("요청","요청 실패")
}
}
아래는 실행시 나오는 런창에서 나오는 정보인데요
W/.myapplication: Accessing hidden method Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard; (light greylist, reflection)
Accessing hidden method Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V (light greylist, reflection)
Accessing hidden method Ldalvik/system/CloseGuard;->warnIfOpen()V (light greylist, reflection)
W/System.err: java.net.UnknownServiceException: CLEARTEXT communication to cose.iptime.org not permitted by network security policy
W/System.err: at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:147)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
W/System.err: at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
W/System.err: at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
W/System.err: at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
W/System.err: at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254)
at okhttp3.RealCall.execute(RealCall.java:92)
W/System.err: at com.example.sjh.myapplication5.MyFirebaseMessagingService.sendRegistrationToServer(MyFirebaseMessagingService.kt:50)
W/System.err: at com.example.sjh.myapplication5.MyFirebaseMessagingService.onNewToken(MyFirebaseMessagingService.kt:33)
at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source:423)
at com.google.firebase.iid.zzg.run(Unknown Source:26)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:7)
W/System.err: at java.lang.Thread.run(Thread.java:764)
D/요청: 요청 실패
V/FA: Inactivity, disconnecting from the service
V/FA: Session started, time: 660680
D/FA: Logging event (FE): session_start(_s), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-295275875790670494}]
V/FA: Connecting to remote service
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 1
V/FA: Inactivity, disconnecting from the service
W/System.err: 라는것이 뜨면서 Okhttp가 오류가 나는것 같아 질문드립니다.
그리구 로그캣에선
2019-01-13 14:06:11.424 1825-1825/? E/netmgr: Failed to open QEMU pipe 'qemud:network': Invalid argument
2019-01-13 14:06:11.424 1825-1825/? E/netmgr: WifiForwarder unable to open QEMU pipe: Invalid argument
2019-01-13 14:06:15.897 1736-1767/? E/storaged: getDiskStats failed with result NOT_SUPPORTED and size 0
라는 문구들이 뜹니다.
제가 너무 두서없이 말한것같네요...
독학으로 배우려다 보니 쉽지가않네요. 설명이 부족하거나 제가 잘못올린것이 있으면 지적 부탁드립니다.