아니요, 필요하지 않습니다. 양방향 통신을 원하지 않으면 장치에서 메시지를 보내지 않습니다.
푸시 메시지 만 수신해야하는 경우 onHandleIntent() 메서드를 사용하여 GcmIntentService() 공용 클래스에서 onReceive()를 통해 메시지 수신을 관리하지만 그 전에는 다음과 같은 기본 구성을 충족해야합니다.
A) 구글이 서비스
메시지를 보내려면 플레이 intalled 것으로한다) 나 구글과 제 3 자 애플리케이션 서버에 등록 된 장치) 인터넷 C에 장치를 연결하기 위해해야 할해야 registration_ids를 저장하고 메시지를 보내기 위해 작업을 수행하는 Google 엔드 포인트로 메시지를 보내려면 타사 서버 앱이 필요합니다. r 특정 조건을 제공 한 모든 registration_ids에 적용하십시오. (XMPP 및 gcm.send 방법을 무시하세요) 모든 주제의
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.1'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
dependencies {
compile project(':libraries:AmbilWarna')
compile files('libs/libGoogleAnalyticsServices.jar')
compile files('libs/commons-net-3.3.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'org.jsoup:jsoup:[email protected]'
compile 'joda-time:joda-time:[email protected]'
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'ch.acra:acra:4.5.0'
compile 'net.rdrei.android.dirchooser:library:[email protected]'
compile 'com.uwetrottmann:trakt-java:3.3.1'
}
def getVersionCode = { ->
try {
def code = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', '--oneline'
standardOutput = code
}
return code.toString().split("\n").size()
}
catch (ignored) {
return -1;
}
}
android {
signingConfigs {
release {
keyAlias '***'
keyPassword '+++'
storeFile file('/home/***')
storePassword '***'
}
}
compileSdkVersion 21
buildToolsVersion '21.1'
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
defaultConfig {
versionCode 30000+getVersionCode()
versionName "3.0." + getVersionCode()
signingConfig signingConfigs.release
}
lintOptions {
abortOnError false
}
productFlavors {
}
}
더 자세한 정보를 원하시면 :
이
구글이 GoogleCloudMessaging 클래스에 액세스 할 수 있도록 Play 서비스를 포함하여 내 build.gradle의 예입니다
Full GCM Client implementation
감사합니다. 그렇게 생각했습니다. 'gcmbaseintentservice' 클래스의 일부인 onMessage 메소드를 언급했습니다. 그러나 클래스가 인식되지 않는 것 같습니다. 왜 그런지 알고 있니? btw 중요한 경우 안드로이드 스튜디오를 사용하고 있습니다. – GM6
아, 죄송합니다. 네가 옳아. 새로운 구현은 더 이상 독립적 인 라이브러리가 아니며 Google Play 서비스의 일부입니다. –
Google에서 깨우 른 Intent를 관리하는 올바른 방법은 GoogleCloudMessaging 클래스의 일부인 getMessageType()입니다. 전체 구현이 상세하게 설명되어있는이 링크를 확인하십시오. 더 궁금하신 점이 있으시면 언제든지 문의하십시오. https://developer.android.com/reference/com/google/android/gms/gcm/GoogleCloudMessaging.html. Android Studio에서 build.gradle 파일에 Google Play 서비스 의존성을 포함시키는 방법에 대한 위의 내 수정을 참조하세요. –