gcm 관련 모듈 도움 주실분

592 views
Skip to first unread message

hye hwan

unread,
May 5, 2013, 9:48:21 PM5/5/13
to appspr...@googlegroups.com
안드로이드 gcm 관련 모듈 성공하신분 도움 주실분 없으신가요?

혹시라도 성공 하신분 있으시면 도움좀 부탁드리겠습니다. ㅜ,ㅜ

2cdm 모듈은 샘플이 있어 어찌저찌 해보았는데.. 구글 정책이 바뀌어서 쓸수가 없네요..

모듈 제작에 성공하신분 있으시면 염치없지만 도움좀  부탁드리겠습니다.

Nature

unread,
May 6, 2013, 8:45:18 PM5/6/13
to appspr...@googlegroups.com
https://code.google.com/apis/console 
여기서 gcm 서비스를 온하시고 

주소줄 보시면 project:00000000 숫자있는데
이 숫자를 복사하셔서 샘플에 붙여넣으시면됩니다.

push key 값은 디비에 가지고 계셔야 됩니다
Gcm.zip

hye hwan

unread,
May 6, 2013, 9:15:01 PM5/6/13
to appspr...@googlegroups.com
정말 감사드립니다.

빨리 감사의 글을 남기고 싶어 파일을 다운받기도전에 글을 남깁니다.

도움 주셔서 다시 한번 감사드리고요~~

항상 행복하시길 바랍니다.~~~

2013년 5월 7일 화요일 오전 9시 45분 18초 UTC+9, Nature 님의 말:

Chinseok Lee

unread,
May 6, 2013, 10:32:05 PM5/6/13
to appspr...@googlegroups.com
앞으로 앱스프레소 지원이 잘 안 될 것으로 예상됩니다. 하이브리드앱을 하실려면, 폰갭으로 갈아타시는 게 좋지 않을까 싶네요.

그리고, 하이브리드 앱을 개발하시지만, Native 개발 (안드로이드는 자바, 아이폰은 Objective-C) 에 대해서도 어느 정도는 알고 계셔야 됩니다.

폰갭 gcm 프로젝트 사이트 링크합니다.




2013/5/7 hye hwan <hhso...@gmail.com>

--
Google 그룹스 '앱스프레소' 그룹에 가입했으므로 본 메일이 전송되었습니다.
이 그룹에서 탈퇴하고 더 이상 이메일을 받지 않으려면 appspresso-k...@googlegroups.com에 이메일을 보내세요.
더 많은 옵션을 보려면 https://groups.google.com/groups/opt_out을(를) 방문하세요.
 
 

성관 김

unread,
May 8, 2013, 9:35:25 PM5/8/13
to appspr...@googlegroups.com
Nature님께서 올려주신 소스 잘 보고 있습니다.
그런데, 제가 워낙이 실력이 없는지라....

전화번호는 alert를 이용해 잘 들어오는데요...
registeration_id값은 기존에 있던 소스 적용을 하니 null값만 계속 들어와서요.
하다하다 어떻게 해야 되는지 몰라 글을 올립니다.

MyPlugin.java에서 

if ("echo".equals(method)) {
String message = context.getParamAsString(0, null);
context.sendResult(message);
}else if("phone".equals(method)){
TelephonyManager tm = null ;
       tm=(TelephonyManager)runtimeContext.getActivity().getSystemService(Context.TELEPHONY_SERVICE);
       String userPhone = tm.getLine1Number();
       if(userPhone != null)
       {
           //KT특이사항
        userPhone = userPhone.replace("+82", "0");
       }
String message = userPhone;
context.sendResult(message);
} else if("getDeviceToken".equals(method)){
       Log.d("test","aaaa");
  SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.runtimeContext.getActivity());
  String registeration_id = preferences.getString("registration_id", null);
  Log.d("test","registeration_id : "+registeration_id);
  context.sendResult(registeration_id);
  }
else {
context.sendError(AxError.NOT_AVAILABLE_ERR);
}

에서 이렇게 설정을 했구요

function getDeviceToken(callback, errback){
  return this.execAsync('getDeviceToken', callback, errback);
  }

window.myplugin = ax.plugin('com.example.ax.gcmtest', {
'echoSync': echoSync,
'echoAsync': echoAsync,
'myPhone' : myPhone,
'getDeviceToken' : getDeviceToken
});

이렇게 해서 myPhone은 alert를 이용해 화면에서 출력되는 것을 확인했는데요..
getDeviceToken는 registeration_id값이 null로 출력이 됩니다.

도움좀 부탁 드립니다.
 

안세웅

unread,
May 8, 2013, 9:56:11 PM5/8/13
to appspr...@googlegroups.com

아래 소스는 제가 실제로 쓰는 구문입니다. 한번 비교해보시는게 ㅎㅎ


function getPushKey(callback, errback, memberId)

{

if(!memberId) {

throw ax.error(ax.INVALID_VALUES_ERR, 'invalid argument!');

}

return this.execAsync('getPushkey', callback, errback, [ memberId||'' ]);

}


window.myplugin = ax.plugin('kr.co.hiedition.bplan', {

"echoSync" : echoSync,

"echoAsync" : echoAsync,

"getPushKey" : getPushKey

});



2013년 5월 9일 오전 10:35, 성관 김 <pulseme...@gmail.com>님의 말:

--
Google 그룹스 '앱스프레소' 그룹의 주제에 가입했으므로 이 메시지를 받으셨습니다.
이 주제에서 탈퇴하려면 https://groups.google.com/d/topic/appspresso-ko/K3BHz51FxCc/unsubscribe?hl=ko을(를) 방문하세요.
이 그룹 및 그룹의 모든 주제에서 탈퇴하려면 appspresso-k...@googlegroups.com에 이메일을 보내세요.
무제 폴더.zip

hye hwan

unread,
May 8, 2013, 10:43:09 PM5/8/13
to appspr...@googlegroups.com
nature님 ..

도움주신거에 감사하며 어떻게든 혼자 해결해보려고 하는데.. 잘되질 않아서
염치불구하고 다시 도움을 요청드립니다.

보내주신 샘플을 플러그인 프로젝트로 연결시키고
project id 값을 변경후에 테스트 해보았는데요..

실행하면.. 에뮬레이터 에서는 "unfortunately, appname has stopped"
실제 단말기로 돌리면 앱이 멈추고 있습니다.

해서 ddm 모니터로 로그를 보니 아래와 같은 메세지가 나옵니다.

Unknown permission com.google.android.2cdm.permission.RECEIVE in package com.example.ax.gcmtest

at com.google.android.gcm.GCMRegistrar.chkDevice(GCmRegistrar.java.83);
at com.google.android.gcm.GCMRegistrar.chkDevice(RuntimeActivityListener.java.24);

어제 오늘 하루종일 보고 있지만..쉽지가 않네요..

AndroidMainifest.axml 내용은 아래와 같습니다.
 

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="@PACKAGE@"

    android:installLocation="@INSTALL_LOCATION@"

    android:versionCode="@VERSION_CODE@"

    android:versionName="@VERSION_NAME@" >

 

    <application

        android:icon="@drawable/ax_icon"

        android:label="@string/ax_name" >

        <activity

            android:name="@ACTIVITY@"

            android:configChanges="orientation|keyboard|keyboardHidden"

            android:screenOrientation="@ACTIVITY_ORIENTATION@"

            android:theme="@ACTIVITY_THEME@" >

 

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

 

        </activity>

 

        <!-- If you want to add another android components, please let them be here. -->

        <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">

<intent-filter>

<action android:name="com.google.android.c2dm.intent.RECEIVE" />

<action android:name="com.google.android.c2dm.intent.REGISTRATION" />

<category android:name="com.example.ax.gcmtest" />

</intent-filter>

</receiver>

        <service android:name="com.example.ax.gcmtest.GCMIntentService" />

    </application>

 

 

    <permission android:name="com.example.ax.gcmtest.permission.C2D_MESSAGE" android:protectionLevel="signature" />

<uses-permission android:name="com.example.ax.gcmtest.permission.C2D_MESSAGE" />

<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.GET_ACCOUNTS" />

<uses-permission android:name="android.permission.USE_CREDENTIALS" />

<uses-permission android:name="android.permission.WAKE_LOCK" />

    @USES_PERMISSION@

 

    @USES_SDK@

 

</manifest>


정말 염치없지만..조그만 더 도움을 주시면 감사하겠습니다.




2013년 5월 6일 월요일 오전 10시 48분 21초 UTC+9, hye hwan 님의 말:

안세웅

unread,
May 8, 2013, 10:44:35 PM5/8/13
to appspr...@googlegroups.com
혹시 플러그인 폴더에 libs 에 gcm.jar 파일을 자바 빌드패스에 추가 하셨나여?


2013년 5월 9일 오전 11:43, hye hwan <hhso...@gmail.com>님의 말:

hye hwan

unread,
May 8, 2013, 10:51:08 PM5/8/13
to appspr...@googlegroups.com
플러그인 폴더의 libs에 gcm.jar에 빌드패스  > config build path.. 로 들어가보니

libraries 탭에 gcm.jar - 플러그인 폴더명/libs 이렇게 표시가 되어있습니다.



2013년 5월 9일 목요일 오전 11시 44분 35초 UTC+9, Nature 님의 말:

안세웅

unread,
May 8, 2013, 10:57:24 PM5/8/13
to appspr...@googlegroups.com
제가 확인할 방법이 없어서 ㅠ.

첨부터 말하자면


첨에 구글 api 사이트 service 탭에서 c2dm을 서비스 on 으로 시키고
프로젝트 번호가 나오는것을 Contant 에 추가를 하고
gcm.jar 파일을 빌드패스에 추가하면 앱은 끝이났습니다

그리고 보내는 쪽에서는 키를 api access 탭에서 

create new server key를 생성 하시면 됩니다.

자세한 설명이 부족하네요 ㅜ.ㅜ.


2013년 5월 9일 오전 11:51, hye hwan <hhso...@gmail.com>님의 말:

hye hwan

unread,
May 8, 2013, 11:10:48 PM5/8/13
to appspr...@googlegroups.com
바쁘신 시간에 답변 주셔서 대단히 감사드립니다.
service 탭에서 c2dm을 서비스 on 
 --> Google Cloud Messaging for Android 이걸 말씀하시거죠?

알려주신대로 설정은 제대로 진행했는데.. 계속 저러네요..

다 지우고..처음부터 차근차근 해보도록 하겠습니다.

다시한번 감사드리고요..

성공하면 답글 남기겠습니다.

그럼 좋은 하루되세요~~


2013년 5월 9일 목요일 오전 11시 57분 24초 UTC+9, Nature 님의 말:

안세웅

unread,
May 8, 2013, 11:13:40 PM5/8/13
to appspr...@googlegroups.com

꼭 성공하시기를!!! 정 안되면 파일을 통째로 한번 보내주세요

2013. 5. 9. 오후 12:10에 "hye hwan" <hhso...@gmail.com>님이 작성:

성관 김

unread,
May 9, 2013, 1:03:40 AM5/9/13
to appspr...@googlegroups.com
Nature 선배님! 바쁘신데 죄송한데요.

context.sendResult(Constant.AppRegId);

값을 못 갖고 오는 경우는 어떻게 처리를 해야 할까요...

이리저리 주신 소스 보아도 소스상에는 틀린게 없는듯한데,  너무 답답합니다. 도움좀 다시 한번 부탁 드립니다.

안세웅

unread,
May 9, 2013, 1:09:34 AM5/9/13
to appspr...@googlegroups.com
구조가 앱이 켜질때 regId 를 받아와서 
execute 할때 값을 javascript 로 이동 시켜주는 원리 입니다
그래서 앱을 켰을때 regId 가 나오지 않는다면 브로드 캐스트 리시버를 살펴 보시는게
좋겠네여

일단 저한테 풀 소스를 다 보내보시졍????


2013년 5월 9일 오후 2:03, 성관 김 <pulseme...@gmail.com>님의 말:

--

성관 김

unread,
May 9, 2013, 2:42:26 AM5/9/13
to appspr...@googlegroups.com
바쁘신데, 정말 죄송합고 고맙습니다.

소스 한번 봐 주십시오.
gcm-test.zip

안세웅

unread,
May 9, 2013, 2:54:22 AM5/9/13
to appspr...@googlegroups.com

    <permission android:name="com.example.ax.test2.permission.C2D_MESSAGE"

android:protectionLevel="signature" />


<uses-permission android:name="com.example.ax.test2.permission.C2D_MESSAGE" />



여기부분에 안드로이드 네임 값이 잘못 된거같네요??


앱 패키징 하실때 아이디값이 어떻게 되죠?

성관 김

unread,
May 9, 2013, 4:58:48 AM5/9/13
to appspr...@googlegroups.com

======================================================

죄송합니다. 

앱 패키징 하실때 아이디값이 어떻게 되죠? 

이 질문이 폴더명 GcmTestPlugin의 아이디값을 말씀하시는 건가요.(아이디값 : com.example.ax.gcmtest  <== 변경 없이 주신 소스 그대로 이구요.)

아니면 실제 작업한(폴더명 test2)의 아이디 값을 말씀하시는 건가요.(아이디값 : com.example.ax.test2 입니다.)


<intent-filter>

<action android:name="com.google.android.c2dm.intent.REGISTRATION" />

<action android:name="com.google.android.c2dm.intent.RECEIVE" />

<category android:name="com.example.ax.test2" />        <=== 이부분하고

</intent-filter>

<service android:name="com.example.ax.gcmtest.GCMIntentService" />   <=== 이부분하고

<permission android:name="com.example.ax.test2.permission.C2D_MESSAGE" android:protectionLevel="signature" />   <=== 이부분하고

<uses-permission android:name="com.example.ax.gcmtest.permission.C2D_MESSAGE" /> <=== 이부분하고


이곳에서 문제가 발생하는가 보내요... 설명해주신 부분으로 보았을때는요...

어떻게 바꾸면 되는지 조언좀 부탁 드립니다.

죄송합니다.


안세웅

unread,
May 9, 2013, 5:00:32 AM5/9/13
to appspr...@googlegroups.com
폴더 명이랑은 상관없고 앱을 처음에 만드실때 쓰신

com.example.ax.test2 를
com.example.ax.gcmtest 로 변경해보시기바랍니다.
 


2013년 5월 9일 오후 5:58, 성관 김 <pulseme...@gmail.com>님의 말:

hye hwan

unread,
May 28, 2013, 3:11:49 AM5/28/13
to appspr...@googlegroups.com
 Nature 님.. GCM 해결하면 답글을 남기기로 했었는데..너무 늦었네요~
혹시라도 보실까 하여 글 남깁니다.

보내주신 소스로 문제는 잘 해결 했었습니다.

다만 IOS와 동시에 개발하던 앱이라서...

폰갭으로 다시 갈아타서 제작 하게되었습니다.
(iphone5 4인치 디스플레이가 지원되질 않아서요..)

제작업 하는라 정신이 없어서 이곳을 찾지 못해 답글이 늦었습니다.

도움 주신부분 너무 감사드립니다.

그럼 항상 좋은 일만 가득하시길 빌겠습니다.



2013년 5월 6일 월요일 오전 10시 48분 21초 UTC+9, hye hwan 님의 말:
안드로이드 gcm 관련 모듈 성공하신분 도움 주실분 없으신가요?
Reply all
Reply to author
Forward
0 new messages