'2014/03'에 해당되는 글 12건

  1. 2014.03.31 php mysql 지원 함수들
  2. 2014.03.31 phpmyadmin 미리 작성된 sql 파일 import 하기
  3. 2014.03.31 데이터베이스 테이블 설계(테이블 수정)
  4. 2014.03.31 데이터베이스 테이블 설계(테이블 생성 및 구조 보기)
  5. 2014.03.31 관계형 데이터베이스의 구조
  6. 2014.03.28 인앱빌링 구현하기 ver3 - 구글번역
  7. 2014.03.27 안드로이드 서버 php 통신(간단히) (11)
  8. 2014.03.27 안드로이드 In-app Billing Version 3 - 구글번역
  9. 2014.03.18 유니티 xml 파일 로드
  10. 2014.03.07 두 벡터간의 거리 구하기

php mysql 지원 함수들

|

http://php.net 에서 다음의 함수들을 찾아보실 수 있고, 자세한 설명과 샘플을

확인하실 수 있습니다. :)

 

mysql_affected_rows -- 최근 MySQL 작업으로 처리된 행(row) 개수를 얻음
mysql_change_user --  현 접속에서 로그인된 사용자를 변경
mysql_client_encoding -- Returns the name of the character set
mysql_close -- MySQL 접속을 닫음
mysql_connect -- MySQL 서버에 접속
mysql_create_db -- MySQL 데이터베이스를 생성
mysql_data_seek -- 내부적인 결과 포인터를 이동
mysql_db_name -- 데이터 결과를 얻음
mysql_db_query -- MySQL 질의문을 전송
mysql_drop_db -- MySQL 데이터베이스를 삭제
mysql_errno -- 최근 MySQL 작업으로 발생한 에러 번호를 반환
mysql_error -- 최근 실행된 MySQL 작업으로 발생한 에러 메시지를 반환
mysql_escape_string --  Escapes a string for use in a mysql_query.
mysql_fetch_array --  결과를 필드이름 색인 또는 숫자 색인으로 된 배열로 반환
mysql_fetch_assoc --  결과를 필드이름 색인으로 된 배열로 반환
mysql_fetch_field --  결과로부터 열 정보를 얻어서 객체로 반환
mysql_fetch_lengths --  결과로부터 각 출력의 길이를 반환
mysql_fetch_object -- 행(row)의 결과를 객체로 얻음
mysql_fetch_row -- 결과를 숫자색인으로 된 배열로 반환
mysql_field_flags --  결과로부터 특정 필드(field)의 상태정보(flag)를 반환
mysql_field_len --  특정 필드의 길이를 반환
mysql_field_name --  결과로부터 특정 필드 이름을 반환
mysql_field_seek --  특정 필드의 오프셋(offset)으로 위치(pointer)를 이동
mysql_field_table --  특정 필드가 속한 테이블 이름을 얻음
mysql_field_type --  결과로부터 특정 필드의 데이터 형(type) 정보를 반환
mysql_free_result -- Free result memory
mysql_get_client_info -- Get MySQL client info
mysql_get_host_info -- Get MySQL host info
mysql_get_proto_info -- Get MySQL protocol info
mysql_get_server_info -- Get MySQL server info
mysql_info --  Get information about the most recent query
mysql_insert_id --  최근 INSERT 작업으로부터 생성된 identifier 값을 반환
mysql_list_dbs --  MySQL 서버에 있는 데이터베이스 이름을 반환
mysql_list_fields -- MySQL 결과의 필드 리스트로 반환
mysql_list_processes -- List MySQL processes
mysql_list_tables -- MySQL 데이터베이스에 있는 테이블 목록을 반환
mysql_num_fields -- 결과로부터 필드 개수를 반환
mysql_num_rows -- 결과로부터 열 개수를 반환
mysql_pconnect --  MySQL 서버와 영구적인 데이터베이스 접속
mysql_ping -- Ping a server connection or reconnect if there is no connection
mysql_query -- Send a MySQL query
mysql_real_escape_string --  Escapes special characters in a string for use in a SQL statement, taking into account the current charset of the connection.
mysql_result -- 결과 데이터를 반환
mysql_select_db -- MySQL 데이터베이스를 선택
mysql_stat -- Get current system status
mysql_tablename -- 필드의 테이블이름을 얻음
mysql_thread_id -- Return the current thread ID
mysql_unbuffered_query --  Send an SQL query to MySQL, without fetching and buffering the result rows


아래는 사용 샘플입니다.

 

<?php
/* 접속하고, 데이터베이스를 선택 */
$link mysql_connect("mysql_host""mysql_user""mysql_password"
)
   or die(
"접속할 수 없습니다 : " mysql_error
());
echo 
"접속 성공"
;
mysql_select_db("my_database") or die("데이터베이스를 선택할 수 없습니다."
);

/* SQL 쿼리 실행하기 */
$query "SELECT * FROM my_table"
;
$result mysql_query($query) or die("쿼리 실패 : " mysql_error
());

/* HTML로 결과 출력하기 */
echo "<table>n"
;
while (
$line mysql_fetch_array($resultMYSQL_ASSOC
)) {
   echo 
"t<tr>n"
;
   foreach (
$line as $col_value
) {
       echo 
"tt<td>$col_value</td>n"
;
   }
   echo 
"t</tr>n"
;
}
echo 
"</table>n"
;

/* 결과셋 해제하기 */
mysql_free_result($result
);

/* 접속 종료 */
mysql_close($link
);
?>


Trackback 0 And Comment 0

phpmyadmin 미리 작성된 sql 파일 import 하기

|


friend2.sql






sql 파일을 미리 만들고




phpmyadmin의 임포트 메뉴로 가서 파일을선택하고 아래의 go를 누르면 sql 파일 명령이 실행되서 테이블이 생성된다.

Trackback 0 And Comment 0

데이터베이스 테이블 설계(테이블 수정)

|
새로운 필드 추가 명령

alter table 테이블명 add 새로운 필드명 필드 타입 [first 또는 after 필드명];

예) 
앞서 만든 friend 테이블에 나이 필드를 (정수형)을 추가하려면 다음과 같이 입력한다.



만약 tel 필드 다음에 휴대폰 번호를 저장하는 hp char(20)인 필드를 추가하려면 다음과 같이 입력한다.

alter table friend add hp char(20) after tel;


필드 삭제 명령


alter table 테이블명 drop 삭제할 필드명1, 삭제할 필드명2;



friend 테이블의 email 필드와 age 필드를 삭제하려면 다음과 같이 입력한다.


alter table friend drop email;

alter table friend drop age;




필드 수정 명령


alter table 테이블명 change 이전 필드명 새로운 필드명 필드 타입;


예)

tel char(20)을 phone int로 변경하고 싶으면


alter table friend chage tel phone int;



필드 타입 수정 명령

alter table 테이블명 modify 필드명 새로운 타입;


name 필드의 타입을 int로 변경하려면


alter table friend modify name int;



데이터 베이스 테이블명 수정 명령

alter table 이전 테이블명 rename 새로운 테이블명;


테이블명을 friend -> student 로 변경하고 싶으면


alter table friend rename student;



데이터베이스 테이블 삭제 명령

drop table 테이블명;


friend 테이블을 삭제하고 싶으면


drop table friend;





Trackback 0 And Comment 0

데이터베이스 테이블 설계(테이블 생성 및 구조 보기)

|

테이블을 직접 만들어보기 전에 간단히 테이블을 설계해보자

간단한 주소록 테이블을 만들어보자.

주소록에는 이름, 주소, 전화번호 등이 들어갈수 있다.



필드명 

타입

설명 

num 

int 

일련번호

name

char(10) 

이름 

address

varchar(80) 또는 char(80) 

주소

tel

char(20) 

전화번호 

email

char(20) 

이메일 주소 


num -> 레코드에 각각 번호를 매기기 위해서 생성했다.

name -> 이름을 저장

address -> 주소 저장 vchar 나 char 사용


vchar 와 char 의 차이는 가변적인 공간인지 아닌지의 차이이다.

vchar 같은 경우에는 입력된 값과 같은 바이트수만 차지하게 된다.

만약 vchar로 80바이트를 선언한 필드의 레코드가 5바이트만 차지하면 5바이트만 차지하게 변한다는 의미이다.


메모리 효율 면에선 vchar 가 우수하고, 속도면에서는 char 가 우수하다.


테이블 생성명령


create table 테이블명 {

필드명1 타입,

필드명2 타입,

.........

PRIMARY KEY(필드명)


};






not null -> not null은 반드시 값을 입력해야 하는 필수 항목을 의미한다.

primary key -> 기본키는 저장된 레코드를 다른 레코드와 구별시켜주는 필드를 의미한다. 필드값은 서로 중복되지 않은 유일한 값을 갖는다.

한 테이블에는 한개의 기본키만 존재하게 된다.



데이터 베이스에 있는 테이블 보기


show tables;



데이터베이스 테이블의 구조 확인하기


desc 테이블명;








Trackback 0 And Comment 0

관계형 데이터베이스의 구조

|

관계형 데이터 베이스이ㅡ 기본 구성 요소 세가지에는

테이블, 필드, 레코드가 있다.




일련번호 

이름 

학번 

수강과목 

성적 

홍길동 

20080835 

모바일게임 

4.3 

정광무

20080335 

게임그래픽 

4.5 

3

허지호

20080336 

게임기획 

4.5 


일련번호, 이름, 학번, 수강과목, 성적 -> 을 나타내는 각각의 열을 필드라고 부른다.

각필드에 해당되는 첫번째 학생의 데이터는 1, 홍길동, 20080835, 등등 인데 이렇게 각 행에 해당되는 데이터를 레코드라고 한다.

즉 레코드 하나에 한 학생의 데이터가 저장된다.

그리고 이 전체의 표가 하나의 테이블이 된다




Trackback 0 And Comment 0

인앱빌링 구현하기 ver3 - 구글번역

|

Implementing In-app Billing (IAB Version 3)

구글 플레이에 인앱 결제는 인앱 결제 요청을 전송하고 구글은 재생 사용하여 응용 프로그램 내 결제 트랜잭션을 관리하기위한 간단, 간단한 인터페이스를 제공합니다. 아래 정보는 버전 3 API를 사용하여 앱내 결제 서비스 응용 프로그램에서 호출을하는 방법의 기초를 다룹니다.

Note: 완전한 구현을 확인하고 응용 프로그램을 테스트하는 방법에 대해, 인 - 앱 판매 제품 교육 클래스를 참조하십시오.교육 과정은 당신의 연결을 설정하는 구글 플레이에서 결제 요청과 응답의 처리를 보내, 당신은 인 - 앱 결제를 할 수 있도록 배경 스레드 관리와 관련된 주요 작업을 처리 할 수있는 편리한 클래스를 포함하는 전체 샘플 앱 결제 응용 프로그램을 제공합니다 main Activity 에서 호출합니다.

당신이 시작하기 전에, 당신은 쉽게 당신이 인 - 앱 결제를 구현할 수 있도록합니다 개념에 익숙해 앱내 결제 개요를 읽을 수 있는지 확인하십시오.

 응용 프로그램에 위치한 앱 결제를 구현하려면 다음을 수행해야합니다 :

  1. 프로젝트에 앱내 결제 라이브러리를 추가합니다.
  2. 여러분의 AndroidManifest.xml 파일을 업데이트합니다.
  3. ServiceConnection를 만들고 IInAppBillingService에 바인딩합니다.
  4. 응용 프로그램 toIInAppBillingService에서 인 - 앱 결제 요청을 보낼 수 있습니다.
  5. 구글 플레이에서 인 - 앱 결제 응답을 처리합니다.

프로젝트에 AIDL 파일을 추가


IInAppBillingService.aidl은 인 - 앱 과금 버전 3 서비스에 대한 인터페이스를 정의하는 안드로이드 인터페이스 정의 언어 (AIDL) 파일입니다. 당신은 IPC 메서드 호출을 호출하여 결제 요청을 할이 인터페이스를 사용합니다.

AIDL 파일을 얻으려면 :

  1. Android SDK Manager 엽니다.
  2. SDK Manager에 expand the Extras 을 선택합니다.
  3. Google Play Billing Library 을 선택합니다..
  4. 다운로드를 완료하기 위해 패키지 설치를 클릭합니다.

IInAppBillingService.aidl 파일은 다음 경로에 설치됩니다.  <sdk>/extras/google/play_billing/.

프로젝트에 AIDL를 추가하려면 :

  1. 안드로이드 프로젝트에 IInAppBillingService.aidl 파일을 복사합니다.
    • 이클립스를 사용한다면:
      1. If you are starting from an existing Android project, open the project in Eclipse. If you are creating a new Android project from scratch, click File > New > Android Application Project, then follow the instructions in the New Android Application wizard to create a new project in your workspace.
      2. In the /src directory, click File > New > Package, then create a package namedcom.android.vending.billing.
      3. Copy the IInAppBillingService.aidl file from <sdk>/extras/google/play_billing/ and paste it into the src/com.android.vending.billing/ folder in your workspace.
    • 이클립스가 아닌 다른 환경을 사용한다면: Create the following directory/src/com/android/vending/billing and copy the IInAppBillingService.aidl file into this directory. Put the AIDL file into your project and use the Ant tool to build your project so that theIInAppBillingService.java file gets generated.
  2. 응용 프로그램을 빌드합니다. 당신은 당신의 프로젝트의 / gendirectory에 IInAppBillingService.java라는 생성 된 파일을 볼 수 있습니다.

Updating Your Application's Manifest


인앱 결제는 구글이 응용 프로그램과 구글 플레이 서버 사이의 모든 통신을 처리하는 응용 프로그램을 재생에 의존합니다.구글 재생 응용 프로그램을 사용하려면 응용 프로그램이 적절한 권한을 요청해야합니다. 당신은 당신의 AndroidManifest.xml 파일에 com.android.vending.BILLING 권한을 추가하여이 작업을 수행 할 수 있습니다. 응용 프로그램이 앱내 결제 권한이 있지만, 결제 요청을 보내려고 시도를 선언하지 않는 경우, 구글의 플레이는 요청을 거부하고 오류로 응답합니다.

To give your app the necessary permission, add this line in your Android.xml manifest file:

<uses-permission android:name="com.android.vending.BILLING" />

Creating a ServiceConnection


응용 프로그램은 응용 프로그램과 구글 플레이 사이의 메시징을 촉진하기 ServiceConnection이 있어야합니다. 최소한 응용 프로그램은 다음을 수행해야합니다 :

  • IInAppBillingService에 바인딩합니다.
  • 구글 응용 프로그램을 재생하려면 (IPC 메서드 호출 등)의 결제 요청을 보낼 수 있습니다..
  • 각 대금 청구 요청과 함께 반환되는 동기 응답 메시지를 처리 할 수 ​​있습니다.

Binding to IInAppBillingService

구글 플레이에 앱내 결제 서비스와의 연결을 설정하려면, IInAppBillingService에 활동을 결합하는 ServiceConnection를 구현합니다.연결이 설정된 후 IInAppBillingService 인스턴스에 대한 참조를 얻을 수있는 onServiceDisconnected 및 onServiceConnected 방법을 재정의합니다. 

IInAppBillingService mService;

ServiceConnection mServiceConn = new ServiceConnection() {
   
@Override
   
public void onServiceDisconnected(ComponentName name) {
       mService
= null;
   
}

   
@Override
   
public void onServiceConnected(ComponentName name,
     
IBinder service) {
       mService
= IInAppBillingService.Stub.asInterface(service);
   
}
};

귀하의 활동의에서 onCreate 메서드에서 bindService 메서드를 호출하여 바인딩을 수행합니다.앱내 결제 서비스 및 사용자가 만든 ServiceConnection의 인스턴스를 참조하는 방법 anIntent을 전달합니다.

@Override
public void onCreate(Bundle savedInstanceState) {    
   
super.onCreate(savedInstanceState);
    setContentView
(R.layout.activity_main);        
    bindService
(new
       
Intent("com.android.vending.billing.InAppBillingService.BIND"),
                mServiceConn
, Context.BIND_AUTO_CREATE);

이제 구글 플레이 서비스와 통신하는 mService 참조를 사용할 수 있습니다. 위 해당 함수 같은 경우

구글 샘플 ver3 IAPHelper 클래스에 정의 되있음.


Important: 당신이 당신의 활동을 완료하면 앱내 결제 서비스에서 바인딩을 해제해야합니다. 당신이 바인딩을 해제하지 않을 경우, 오픈 서비스 연결 장치의 성능이 저하 될 수 있습니다. 이 예제에서는 활동의들의 OnDestroy 메서드를 재정 의하여 mServiceConn라는 앱내 결제에 대한 서비스 연결에 바인딩 해제 작업을 수행하는 방법을 보여줍니다.

@Override
public void onDestroy() {
   
super.onDestroy();
   
if (mService != null) {
        unbindService
(mServiceConn);
   
}  
}

IInAppBillingService에 결합 서비스 연결의 전체 구현을 위해, 인 - 앱 판매 제품 교육 클래스 및 관련 샘플을 참조하십시오.

Making In-app Billing Requests


응용 프로그램이 구글 플레이에 연결 한 후에는 응용 프로그램 내 제품의 구매 요청을 시작할 수 있습니다. 구글 플레이는 사용자가 자신의 지불 방법을 입력 할 수있는 체크 아웃 인터페이스를 제공하여 응용 프로그램이 직접 지불 트랜잭션을 처리 할 필요가 없습니다.항목이 구입되면, 구글의 플레이는 사용자가 해당 항목의 소유권을 가지고 있으며, 그것이 소비 될 때까지 동일한 제품 ID와 다른 아이템을 구입하는 사용자를 방지 함을 인식합니다. 당신은 항목이 응용 프로그램에서 소비되는 방법을 제어하고, 구글은 다시 구입을위한 항목을 사용할 수 있도록 재생 알릴 수 있습니다. 또한 구글은 사용자가 빠르고 만들어진 구매 목록을 검색 재생 조회 할 수 있습니다. 당신은 당신의 사용자가 응용 프로그램을 시작할 때 사용자의 구매를 복원하려는 경우에 유용합니다.

Querying for Items Available for Purchase

응용 프로그램에서, 당신은 앱내 결제 버전 3 API를 사용하여 Google 플레이에서 항목 상세 정보를 조회 할 수 있습니다. 먼저 각 문자열이 살 수있는 항목에 대한 제품 ID입니다 키 "ITEM_ID_LIST"와 제품 ID의 문자열 ArrayList에 포함 된 번들을 작성, 인 - 앱 결제 서비스에 대한 요청을 전달합니다.

ArrayList<String> skuList = new ArrayList<String> ();
skuList
.add("premiumUpgrade");
skuList
.add("gas");
Bundle querySkus = new Bundle();
querySkus
.putStringArrayList(“ITEM_ID_LIST”, skuList);

구글 플레이에서이 정보를 검색 앱내 결제 버전 3 API에 getSkuDetails의 메서드를 호출하는 방법에게 인 - 앱 결제 API 버전 ( "3")를 전달하려면, 당신의 전화 응용 프로그램, 구입 형태의 패키지 이름 ( "inapp"), 당신이 만든 번들.

Bundle skuDetails = mService.getSkuDetails(3, 
   getPackageName
(), "inapp", querySkus);

만약 결과가 성공하면 리턴해준다. BILLING_RESPONSE_RESULT_OK (0) 값을.

Warning: 주 스레드에 getSkuDetails 메서드를 호출하지 마십시오. 이 메서드를 호출하면 주 스레드를 차단할 수있는 네트워크 요청을 트리거합니다. 대신, 별도의 스레드를 만들고 해당 스레드 내부에서 getSkuDetails 메서드를 호출합니다.

구글 플레이에서 가능한 모든 응답 코드를 참조하십시오 인 - 앱 결제 참조 (영문)를 참조하십시오. 

조회 결과가 키 DETAILS_LIST의 String ArrayList에 저장됩니다.구매 정보는 JSON 형식의 문자열에 저장됩니다. 반환되는 제품 상세 정보의 종류를 확인하려면, 앱 결제 참조를 참조하십시오. 

이 예에서 skuDetails 번들에서 - 응용 프로그램 항목에 대한 가격을 검색하는 이전의 코드에서 반환.

int response = skuDetails.getInt("RESPONSE_CODE");
if (response == 0) {
   
ArrayList<String> responseList
     
= skuDetails.getStringArrayList("DETAILS_LIST");
   
   
for (String thisResponse : responseList) {
     
JSONObject object = new JSONObject(thisResponse);
     
String sku = object.getString("productId");
     
String price = object.getString("price");
     
if (sku.equals("premiumUpgrade")) mPremiumUpgradePrice = price;
     
else if (sku.equals("gas")) mGasPrice = price;
   
}
}

Purchasing an Item

앱에서 구매 요청을 시작하려면 앱내 결제 서비스에 getBuyIntent 메서드를 호출합니다. 메서드에 전달하는 인 - 앱 결제 API 버전 ( "3"), 사용자 통화 앱, 구매하는 품목에 대한 제품 ID의 패키지 이름, 구입 형태 ( "inapp"또는 "서브") 및 developerPayload 문자열입니다.developerPayload 문자열은 사용자가 구글의 구매 정보와 함께 다시 보낼 플레이 할 추가 인수를 지정하는 데 사용됩니다.

Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(),
   sku
, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");

요청이 성공하면, 반환 된 번들은 당신이 구입 흐름을 시작하는 데 사용할 수있는 BILLING_RESPONSE_RESULT_OK (0) 및 aPendingIntent의 응답 코드가 있습니다. 구글 플레이에서 가능한 모든 응답 코드를 참조하십시오 인 - 앱 결제 참조 (영문)를 참조하십시오. 다음으로, 키 BUY_INTENT와 응답 번들에서 PendingIntent의 압축을 풉니 다.

PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");

구매 거래를 완료하려면 startIntentSenderForResult 메서드를 호출하고 사용자가 만든 PendingIntentthat를 사용합니다. 이 예에서, 요청 코드 (1001)의 임의의 값을 사용하고있다.

startIntentSenderForResult(pendingIntent.getIntentSender(),
   
1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0),
   
Integer.valueOf(0));

구글 재생 응용 프로그램의는 onActivityResult 메서드로 PendingIntent에 대한 응답을 보냅니다. TheonActivityResult 방법은 Activity.RESULT_OK (1) 또는 Activity.RESULT_CANCELED의 결과 코드를가집니다 (0). 응답 의도에 반환되는 주문 정보의 종류를 확인하려면, 인 - 앱 결제 참조를 참조하십시오. 

주문에 대한 구매 데이터는 예를 들어, 응답 의도에 INAPP_PURCHASE_DATA 키에 매핑 된 JSON 형식의 문자열입니다 :

'{ 
   "orderId":"12999763169054705758.1371079406387615",
   "packageName":"com.example.app",
   "productId":"exampleSku",
   "purchaseTime":1345678900000,
   "purchaseState":0,
   "developerPayload":"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ",
   "purchaseToken":"rojeslcdyyiapnqcynkjyyjh"
 }'

앞의 예에서 계속, 당신은 응답 의도에서 응답 코드, 구매 데이터 및 서명을 얻을..

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   
if (requestCode == 1001) {          
     
int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
     
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
     
String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
       
     
if (resultCode == RESULT_OK) {
         
try {
           
JSONObject jo = new JSONObject(purchaseData);
           
String sku = jo.getString("productId");
            alert
("You have bought the " + sku + ". Excellent choice,
               adventurer!"
);
         
}
         
catch (JSONException e) {
             alert
("Failed to parse purchase data.");
             e
.printStackTrace();
         
}
     
}
   
}
}

Security Recommendation: When you send a purchase request, create a String token that uniquely identifies this purchase request and include this token in the developerPayload.You can use a randomly generated string as the token. When you receive the purchase response from Google Play, make sure to check the returned data signature, the orderId, and the developerPayload String. For added security, you should perform the checking on your own secure server. Make sure to verify that the orderId is a unique value that you have not previously processed, and the developerPayload String matches the token that you sent previously with the purchase request.

Querying for Purchased Items

To retrieve information about purchases made by a user from your app, call the getPurchases method on the In-app Billing Version 3 service. Pass in to the method the In-app Billing API version (“3”), the package name of your calling app, and the purchase type (“inapp” or "subs").

Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);

The Google Play service returns only the purchases made by the user account that is currently logged in to the device. If the request is successful, the returned Bundle has a response code of 0. The response Bundle also contains a list of the product IDs, a list of the order details for each purchase, and the signatures for each purchase.

To improve performance, the In-app Billing service returns only up to 700 products that are owned by the user when getPurchase is first called. If the user owns a large number of products, Google Play includes a String token mapped to the key INAPP_CONTINUATION_TOKEN in the response Bundle to indicate that more products can be retrieved. Your application can then make a subsequent getPurchases call, and pass in this token as an argument. Google Play continues to return a continuation token in the response Bundle until all products that are owned by the user has been sent to your app.

For more information about the data returned by getPurchases, see In-app Billing Reference. The following example shows how you can retrieve this data from the response.

int response = ownedItems.getInt("RESPONSE_CODE");
if (response == 0) {
   
ArrayList<String> ownedSkus =
      ownedItems
.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
   
ArrayList<String>  purchaseDataList =
      ownedItems
.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
   
ArrayList<String>  signatureList =
      ownedItems
.getStringArrayList("INAPP_DATA_SIGNATURE");
   
String continuationToken =
      ownedItems
.getString("INAPP_CONTINUATION_TOKEN");
   
   
for (int i = 0; i < purchaseDataList.size(); ++i) {
     
String purchaseData = purchaseDataList.get(i);
     
String signature = signatureList.get(i);
     
String sku = ownedSkus.get(i);
 
     
// do something with this purchase information
     
// e.g. display the updated list of products owned by user
   
}

   
// if continuationToken != null, call getPurchases again
   
// and pass in the token to retrieve more items
}

Consuming a Purchase

You can use the In-app Billing Version 3 API to track the ownership of purchased in-app products in Google Play. Once an in-app product is purchased, it is considered to be "owned" and cannot be purchased from Google Play. You must send a consumption request for the in-app product before Google Play makes it available for purchase again.

Important: Managed in-app products are consumable, but subscriptions are not.

How you use the consumption mechanism in your app is up to you. Typically, you would implement consumption for in-app products with temporary benefits that users may want to purchase multiple times (for example, in-game currency or equipment). You would typically not want to implement consumption for in-app products that are purchased once and provide a permanent effect (for example, a premium upgrade).

To record a purchase consumption, send the consumePurchase method to the In-app Billing service and pass in the purchaseToken String value that identifies the purchase to be removed. The purchaseToken is part of the data returned in the INAPP_PURCHASE_DATA String by the Google Play service following a successful purchase request. In this example, you are recording the consumption of a product that is identified with the purchaseToken in thetoken variable.

int response = mService.consumePurchase(3, getPackageName(), token);

Warning: Do not call the consumePurchase method on the main thread. Calling this method triggers a network request which could block your main thread. Instead, create a separate thread and call the consumePurchasemethod from inside that thread.

It's your responsibility to control and track how the in-app product is provisioned to the user. For example, if the user purchased in-game currency, you should update the player's inventory with the amount of currency purchased.

Security Recommendation: You must send a consumption request before provisioning the benefit of the consumable in-app purchase to the user. Make sure that you have received a successful consumption response from Google Play before you provision the item.

Implementing Subscriptions

Launching a purchase flow for a subscription is similar to launching the purchase flow for a product, with the exception that the product type must be set to "subs". The purchase result is delivered to your Activity'sonActivityResult method, exactly as in the case of in-app products.

Bundle bundle = mService.getBuyIntent(3, "com.example.myapp",
   MY_SKU
, "subs", developerPayload);

PendingIntent pendingIntent = bundle.getParcelable(RESPONSE_BUY_INTENT);
if (bundle.getInt(RESPONSE_CODE) == BILLING_RESPONSE_RESULT_OK) {
   
// Start purchase flow (this brings up the Google Play UI).
   
// Result will be delivered through onActivityResult().
   startIntentSenderForResult
(pendingIntent, RC_BUY, new Intent(),
       
Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
}

To query for active subscriptions, use the getPurchases method, again with the product type parameter set to "subs".

Bundle activeSubs = mService.getPurchases(3, "com.example.myapp",
                   
"subs", continueToken);

The call returns a Bundle with all the active subscriptions owned by the user. Once a subscription expires without renewal, it will no longer appear in the returned Bundle.

Securing Your Application


To help ensure the integrity of the transaction information that is sent to your application, Google Play signs the JSON string that contains the response data for a purchase order. Google Play uses the private key that is associated with your application in the Developer Console to create this signature. The Developer Console generates an RSA key pair for each application.

Note:To find the public key portion of this key pair, open your application's details in the Developer Console, then click on Services & APIs, and look at the field titled Your License Key for This Application.

The Base64-encoded RSA public key generated by Google Play is in binary encoded, X.509 subjectPublicKeyInfo DER SEQUENCE format. It is the same public key that is used with Google Play licensing.

When your application receives this signed response you can use the public key portion of your RSA key pair to verify the signature. By performing signature verification you can detect responses that have been tampered with or that have been spoofed. You can perform this signature verification step in your application; however, if your application connects to a secure remote server then we recommend that you perform the signature verification on that server.

For more information about best practices for security and design, see Security and Design.


Trackback 0 And Comment 0

안드로이드 서버 php 통신(간단히)

|

안드로이드가 웹과 통신을 하기 위해선 아래 두가지가 필요하다.


1. 웹 서버 (php)

2. 인터넷 연결이 가능한 안드로이드 단말기 or 안드로이드 시뮬레이터


우리는 안드로이드 단말에서 정말 간단한 php 문을 호출할 생각이다.(나중에 응용가능하게)

웹 서버 같은경우에 apm 이나 wpn-xm 등을 설치해서 구축할수 있다.

설치방법은 구글신에게 물어보자.



php 코드 부분

먼저

값을 주고 받을 php 를 만든다.

아래는 아주 간단히 값을 받고 값을 전달하는 php문이다.


php 파일 이름은 phpTest.php 이다. 텍스트 편집기로 파일을 만들고 저장하자.

필자는 notpad++을 사용했다.


post 방식으로 각각 name, age, sex 라는 변수를 받아와

출력하는 간단한 php 입니다.



해당 php 파일을 자신의 서버에 올립시다.

아래 제가 생각하는 php에 대한 간단한 생각들.


php 통신

-보내주는건 많이 보내줄수있는듯 get 방식이든 post 방식이든 get방식같은경우에 글자수가 제한이 있고 주소창에서 입력이 가능하므로 결국엔 post 방식으로 보내주는게 안전할듯.

받을때는 echo 로 출력된 정보를 받는다고 생각하면 편할거같음. 받는 데이터 같은경우에 웹에있는 데이터를 받는다고 생각됨.

여러개의 데이터를 전송받기 위해서는 echo 에서 구분자를 이용한 방법이나 결국 json 형식으로 받는 수 밖에 없음(아님 xml)



결국 결론은 안드로이드 단말에서 php 서버에 보낼수 있는 변수들은 무제한이고, 받을수 있는 값들은 php 문에 출력되는 echo 문들 이다.

결국 이렇기 때문에 많은 데이터를 받을때는(mysql 사용등) json 형식같은 것을 사용해서 php 값들받게 되는것 같다.



안드로이드 코드부분

우리가 만들 안드로이드 코드는

버튼을 누르면 php 웹에 접속해서 원하는 값을 받는 코드입니다.

제일 먼저 해야될것은 AndroidMainfest에 인터넷이 가능하도록 퍼미션을 설정하는 것입니다.





그리고 active_main.xml 에서 버튼과 텍스트 뷰를 추가합니다.







허니콤이후로 네트워크 접속시 별도의 스레드를 돌려야 오류가 나지 않습니다.

AsyncTask를 사용합니다.







urlpath 에는 자기가 접속할 php 주소를 입력합니다.

onCreate 함수(엑티비티가 처음 시작할때 무조건 실행되는 함수)에서 

버튼과 텍스트뷰를 찾고 버튼을 클릭했을시에 HttpTask를 실행합니다.(AsyncTask)


  bn.setOnClickListener(new Button.OnClickListener(){
            public void onClick(View v) {

              new HttpTask().execute();               
            }           
        });




아래는 AsyncTask 입니다. 세번째 인자의 String를 입력했는데 이 값은 

doInBackground의 반환값이며, onPostExecute의 매개변수가 됩니다.

doInBackground의 반환값이 onPostExcute의 인자로 전달된다고 생각하면 될것 같습니다.

자세한 내용은 AsyncTask로 검색하면 나올것입니다.


php 상에서 post 값으로 받기 때문에 HttpPost 로 선언해주고

넘길 값들을 Vector 에 저장한후 웹으로 보내줍니다.




onPostExcute 에서 텍스트뷰를 변경해줍니다. onPostExcute는 doinBackground 가 실행된후 실행되는 함수이며,

안드로이드 메인 ui 같은경우에는 여기서 변경해주어야 에러가 나지 않습니다.








public class MainActivity extends Activity {

    Button bn;
    TextView result;
   
   
    //접속할주소
    private final String urlPath = "";
    private final String TAG = "PHPTEST";
   
    @Override
    protected void onCreate(Bundle savedInstanceState) {      
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
        bn = (Button)findViewById(R.id.btn);
        result = (TextView)findViewById(R.id._result);
       
        bn.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                new HttpTask().execute();   
            }
           
        });
           
    }
   
    class HttpTask extends AsyncTask<Void, Void, String>{

        @Override
        protected String doInBackground(Void... voids) {
            // TODO Auto-generated method stub
            try{
                HttpPost request = new HttpPost(urlPath);
                //전달할 인자들
                Vector<NameValuePair> nameValue = new Vector<NameValuePair>();
                nameValue.add(new BasicNameValuePair("name", "홍길동"));
                nameValue.add(new BasicNameValuePair("age", "24"));
                nameValue.add(new BasicNameValuePair("sex", "male"));               
               
                //웹 접속 - utf-8 방식으로
                HttpEntity enty = new UrlEncodedFormEntity(nameValue, HTTP.UTF_8);
                request.setEntity(enty);
               
                HttpClient client = new DefaultHttpClient();
                HttpResponse res = client.execute(request);
                //웹 서버에서 값받기
                HttpEntity entityResponse = res.getEntity();
                InputStream im = entityResponse.getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(im, HTTP.UTF_8));
               
                String total = "";
                String tmp = "";
                //버퍼에있는거 전부 더해주기
                //readLine -> 파일내용을 줄 단위로 읽기
                while((tmp = reader.readLine())!= null)
                {
                    if(tmp != null)
                    {
                        total += tmp;
                    }
                }
                im.close();
                //결과창뿌려주기 - ui 변경시 에러
                //result.setText(total);
                return total;               
            }catch(UnsupportedEncodingException e){
                e.printStackTrace();
            }catch(IOException e){
                e.printStackTrace();
            }
            //오류시 null 반환
            return null;
        }
        //asyonTask 3번째 인자와 일치 매개변수값 -> doInBackground 리턴값이 전달됨
        //AsynoTask 는 preExcute - doInBackground - postExecute 순으로 자동으로 실행됩니다.
        //ui는 여기서 변경
        protected void onPostExecute(String value){
            super.onPostExecute(value);
            result.setText(value);
        }       
    }      
}



Trackback 0 And Comment 11
  1. 구독 2014.05.18 22:53 address edit & del reply

    그..HttpTask가 다른 클래스인데 urlPath가 어떻게 불러와진거죠???

    • Favicon of https://hyunity3d.tistory.com BlogIcon 히아레인 2014.05.19 08:11 신고 address edit & del

      HttpTask 는 MainActivity안에 내부 클래스로 설정하였습니다.

  2. 감사 2014.05.21 20:00 address edit & del reply

    다음과 같은 부분에 컴파일 에러나는데 어떻게 해야하나요?
    - 클릭 리스너 부분에 (view)-> 이부분
    - Vector<~>
    - super.onOptionsItemSelected(item);

  3. Favicon of https://taetanee.tistory.com BlogIcon 테타니 2014.08.16 03:25 신고 address edit & del reply

    똑같이 했는데 실행오류 '*****이(가) 중지되었습니다'가 나네요.
    죄송하지만 프로젝트를 보내주실 수 있는지요ㅠㅠ
    xpxksl@gmail.com
    염치불구하고 부탁드립니다!

    • Favicon of https://hyunity3d.tistory.com BlogIcon 히아레인 2014.08.19 09:49 신고 address edit & del

      최근에 확인해본결과 수정한거라 똑같이 하시면 실행오류 안뜹니다.
      해당 프로젝트 파일은 없습니다.

  4. 좋은글감사해요 2014.10.01 23:51 address edit & del reply

    올려주신 글로 실습중인데요
    버튼클릭시 아무 반응이 없더라구요
    해서 로그를 보니
    HttpHostConnectException: Connection to http://ip주소 .php refused

    ConnectException : http://ip주소.php : connect failed:EHOSTUNREACH
    이렇게 2개의 익셉션이 떠서 보니까
    컴퓨터상에서는 웹브라우져로 접근해서 echo부분확인이 되는데
    안드로이드에서 똑같이 http주소로 접근하니 없는페이지로 뜨더라구요
    웹페이지를 표시할 수 없습니다. 이 화면이요

    구글링으로 방화벽과 dmz? 부분을 해봤는데 여전하네요ㅠㅠ
    혹시 해결방법 아시나요? 라우터문제라고도 하는데.. 혹시 아는부분있으시면 답변 부탁좀 드립니다.
    2일째 붙잡고있네요ㅠㅠ

    • Favicon of https://hyunity3d.tistory.com BlogIcon 히아레인 2014.10.02 09:13 신고 address edit & del

      먼저 해당 주소로 안드로이드 기기에서 접속해 보세요.
      접속이 되나 확인해보시고 안되면 외부에서 접속이 불가능 한겁니다.
      <?php
      echo "test";
      ?>
      이런식으로 php 페이지를 만들어 들어가서 test라는 글자가 잘뜨나 확인하면 됩니다.

      외부에서 접속이 불가능하면 해당 컴퓨터환경에서 포트포워딩을 열어 80번 포트를 열어주거나 dmz를 열어주셔야됩니다.

  5. 잘모르겟어요 2014.11.22 15:38 address edit & del reply

    음 안드로이드와 php연동 연습중에있습니다. 이거 그대로 하면 버튼 누르면
    <!DOCTYPE HTML PUBLIC"-//IETF//DTD HTML 2.0//EN"><html><head><title>403Forbidden</title></head><body><h1>Forbidden</h1><p>You don't have permission to access/text.phpon(Win64)PHP/5.5.12 Server at 192.168.123.126 Port 80</address></body></html> 이렇게나오는데 무엇이 잘못된걸까요,,모르겠습니다.

  6. asd 2015.01.27 14:39 address edit & del reply

    이거 그대로 php파일만들어서 실행하는데
    바로 오류뜨고 강제종료되던데..되는소스맞아요 ??

  7. 잘봤습니다. 2015.01.28 11:07 address edit & del reply

    프로그램 실행하자마자 오류로 인해 종료되었꼬 logcat을 보니 이렇게 떳는데 이유가무었을까요 ?
    블로그 글과 똑같이 작성했습니다...ㅠㅠㅠ

    01-28 10:59:17.836: E/(10924): Device driver API match
    01-28 10:59:17.836: E/(10924): Device driver API version: 23
    01-28 10:59:17.836: E/(10924): User space API version: 23
    01-28 10:59:17.836: E/(10924): mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Fri Nov 29 14:18:37 KST 2013
    01-28 10:59:17.901: D/OpenGLRenderer(10924): Enabling debug mode 0
    01-28 10:59:29.356: W/dalvikvm(10924): threadid=12: thread exiting with uncaught exception (group=0x42397700)
    01-28 10:59:29.356: E/AndroidRuntime(10924): FATAL EXCEPTION: AsyncTask #1
    01-28 10:59:29.356: E/AndroidRuntime(10924): java.lang.RuntimeException: An error occured while executing doInBackground()
    01-28 10:59:29.356: E/AndroidRuntime(10924): at android.os.AsyncTask$3.done(AsyncTask.java:299)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at java.lang.Thread.run(Thread.java:841)
    01-28 10:59:29.356: E/AndroidRuntime(10924): Caused by: java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=susemi.pe.kr/test/index.php
    01-28 10:59:29.356: E/AndroidRuntime(10924): at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:591)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:293)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at com.example.dbtest3.MainActivity$HttpTask.doInBackground(MainActivity.java:73)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at com.example.dbtest3.MainActivity$HttpTask.doInBackground(MainActivity.java:1)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at android.os.AsyncTask$2.call(AsyncTask.java:287)
    01-28 10:59:29.356: E/AndroidRuntime(10924): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
    01-28 10:59:29.356: E/AndroidRuntime(10924): ... 4 more
    01-28 10:59:31.646: I/Process(10924): Sending signal. PID: 10924 SIG: 9

안드로이드 In-app Billing Version 3 - 구글번역

|

In-app Billing Version 3

인 - 앱 결제 버전 3 API는 쉽게 당신이 당신의 응용 프로그램에 인 - 앱 결제를 통합 할 수 있습니다. 이 버전의 특징은 개선 된 동기 구매 흐름, 쉽게 소비 제품의 소유권을 추적 할 수있는 API 및 응용 프로그램 내 구입 데이터의 로컬 캐싱 (가) 있습니다.

Product Types


당신은이 제품의 종류, 상품, 가격, 설명, 등, 구글 플레이 개발자 콘솔을 사용하여 제품을 정의합니다. 자세한 내용은 인 - 앱 결제 관리를 참조하십시오.버전 3 API는 관리되는 응용 프로그램 내 제품 및 구독을 지원합니다.

Managed In-app Products

관리되는 응용 프로그램 내 제품은 자신의 소유권 정보가 구글 플레이에 의해 추적 및 관리가 항목입니다. 사용자가 관리되는 응용 프로그램 내 아이템을 구입하면, 구글은 상점에게 사용자별로 각 항목에 대한 구매 정보를 재생합니다. 이것은 나중에 구글이 특정 사용자가 구매 한 상품의 상태를 복원 할 수있는 시간에 재생 쿼리 할 수 ​​있습니다. 그들은 장치를 변경하면, 사용자가 응용 프로그램을 제거하거나해도이 정보는 구글 플레이 서버에 영구적이다.

당신은 버전 3 API를 사용하는 경우, 당신은 또한 응용 프로그램 내에서 항목을 관리 사용할 수 있습니다. 일반적으로 (예 : 게임 중 통화, 연료, 또는 마법의 주문 같은) 여러 번 구입 할 수있는 항목에 대한 소비를 구현하는 것입니다. 일단 당신이 항목을 소비 할 때까지 관리 항목이 구글 플레이에 소비 요청을 보내, 다시 구입할 수 없습니다, ​​구입했습니다. - 응용 제품 소비에 대한 자세한 내용을 보려면, 항목 사용을 참조하십시오

Subscriptions

가입하면 매월 또는 매년 반복 청구하여 응용 프로그램 내에서 사용자에게 콘텐츠, 서비스 또는 기능을 판매 할 수 앱내 결제에서 제공하는 제품의 유형입니다. 당신은 응용 프로그램이나 게임의 모든 유형에서, 디지털 콘텐츠의 거의 모든 유형에 대한 구독을 판매 할 수 있습니다. 구독이 작동하는 방식을 이해하려면, 인 - 앱 결제 구독을 참조하십시오.

Important: Unlike in-app products, subscriptions cannot be consumed.

Purchasing Items


Figure 1. The basic sequence for a purchase request.

인앱결제 3의 일반적인 구매 흐름

  1. application 은  용하는 인 - 앱 결제 API의 대상 버전이 지원되는지 확인하는 isBillingSupported 요청을 Google Play 에 을 보냅니다. (버전확인단계)
  2. application 이 시작되거나 사용자가 로그인하면, 사용자가 소유하는 어떤 항목을 결정하는 구글 플레이에 확인하는 좋은 방법입니다. 사용자의 응용 프로그램 내 구입을 조회하려면, getPurchases 요청을 ​​보냅니다.요청이 성공적이면, 구글 Play를 구매 한 품목, 개별 구매 상세 목록 및 구매에 대한 서명리스트 제품 ID 목록을 포함하는 Bundle을 반환한다.
  3. 보통, 당신은 구입에 사용할 수있는 제품의 사용자에게 알리는 것이 좋습니다. 당신이 구글 플레이에 정의 된 응용 프로그램 내 제품의 세부 사항을 조회하려면, 응용 프로그램 getSkuDetails 요청을 ​​보낼 수 있습니다. 당신은 쿼리 요청에 제품 ID의 목록을 지정해야합니다. 요청이 성공하면, 구글의 플레이는 제품의 가격, 제목, 설명 및 구매 유형 등 제품의 세부 사항을 포함하는 Bundle 반환합니다.
  4. 응용 제품이 사용자가 소유하지 않은 경우, 당신은 그것을 구매를 시작할 수 있습니다.구매 요청을 시작하려면 응용 프로그램이 다른 매개 변수와 함께 구매하는 항목의 제품 ID를 지정 getBuyIntent 요청을 보냅니다. 당신은 개발자 콘솔에서 새 응용 프로그램 내 제품을 만들 때 제품 ID를 기록한다.
    1. 구글 플레이는 응용 프로그램 구입을위한 체크 아웃 UI를 시작하는 데 사용하는 PendingIntent가 포함 된 번들을 반환합니다.
    2. 응용 프로그램이 startIntentSenderForResult 메서드를 호출하여 보류중인 의도를 시작합니다.
    3. 체크 아웃 흐름 완료 (즉, 사용자가 성공적으로 아이템을 구매하거나 구매를 취소입니다), 구글의 플레이는는 onActivityResult 메서드에 응답 의도를 보낼 때.는 onActivityResult의 결과 코드는 구입이 성공 또는 취소 여부를 나타내는 결과 코드가 있습니다. 응답 의도는 구글이 유일하게이 구매 거래를 식별하는 플레이에 의해 생성 된 purchaseToken 문자열을 포함하여 구입 한 항목에 대한 정보가 포함되어 있습니다.의도는 개인 개발자 키로 서명 구입의 서명이 포함되어 있습니다.

To learn more about the Version 3 API calls and server responses, see In-app Billing Reference.

Consuming In-app Products


당신은 인앱 제품의 사용자의 소유권을 추적하기 위해 소비 메커니즘을 사용할 수 있습니다.

버전 3에서는 모든 인앱 제품을 관리합니다. 이것은 모든 앱에서 아이템 구매에 대한 사용자의 소유권이 구글 플레이에 의해 유지되는 것을 의미하고, 필요할 때 응용 프로그램은 사용자의 구매 정보를 조회 할 수 있습니다. 사용자가 성공적으로 앱에서 제품을 구입하면, 그 구매는 Google 플레이에 기록됩니다.앱에서 상품이 구입되면, 그것은 "소유"것으로 간주된다."소유"상태에있는 인앱 제품은 구글 플레이에서 구입 할 수 없습니다. 구글의 플레이를 다시 구입이 가능하게하기 전에 "소유"- 응용 제품에 대한 소비 요청을 보내야합니다.- 응용 제품을 소비하는 것은 "소유자가없는"상태로 복귀하고 이전의 구매 데이터를 삭제합니다.

Figure 2. The basic sequence for a consumption request.

제품의 사용자가 소유 한 목록을 검색하려면 응용 프로그램 getPurchases 구글이 플레이에 전화를 보냅니다. 응용 프로그램은 consumePurchase 호출을 전송하여 소비 요구를 할 수 있습니다. 요청 인수에, 당신은 그것을 구입 한 경우는 구글 플레이에서 얻은 - 응용 제품의 고유 한 purchaseToken 문자열을 지정해야합니다. 구글 플레이는 소비가 성공적으로 촬영 한 경우를 나타내는 상태 코드를 반환합니다.

Non-consumable and Consumable In-app Products

그것은 당신이 아닌 소모품이나 소모품으로 앱내 제품을 처리 할 것인지 여부를 결정하기 위해 당신에게 모든 것이 달렸습니다.

Non-consumable Items
일반적으로, 당신은 당신의 응용 프로그램에서 한 번 구입하고 영구적 인 혜택을 제공 할 수있는 앱 제품에 대한 소비를 구현하지 않을 것입니다. 한 번 구입 한, 이러한 항목은 영구적으로 사용자의 Google 계정에 연결됩니다. 비 소모품 - 응용 제품의 예는 프리미엄 업그레이드 또는 수준의 팩입니다.
Consumable items
반면에, 당신은 구입 여러 번 사용할 수 할 수있는 항목에 대한 소비를 구현할 수 있습니다. 일반적으로 이러한 항목은 특정 일시적인 효과를 제공합니다. 예를 들어, 사용자의 게임 내 캐릭터의 라이프 포인트를 얻을 수 있습니다 또는 자신의 인벤토리에 추가 금화를 얻을 수 있습니다. 응용 프로그램에서 구입 한 상품의 장점이나 효과를 분배하면 응용 프로그램 내 제품을 프로비저닝이라고합니다. 당신은 통제하고 인앱 제품이 사용자에게 프로비저닝하는 방법을 추적 할 책임이 있습니다.

Important: Before provisioning the consumable in-app product in your application, you must send a consumption request to Google Play and receive a successful response indicating that the consumption was recorded.

Managing consumable purchases in your application

여기에 소비 - 응용 제품을 구입하기위한 기본 흐름은 :

  1. getBuyIntent 호출을 구매 흐름을 시작합니다
  2. 구매가 성공적으로 완료하면 응답 Bundlefrom 구글 플레이를 나타내는 받기
  3. 구입에 성공하면, consumePurchase를 호출하여 구입을 소비
  4. 소비가 성공적으로 완료 여부를 나타내는 구글 플레이에서 응답 코드를 얻을.
  5. 소비가 성공하면 제공 응용 프로그램의 제품입니다.

사용자가 응용 프로그램에서 시작하거나 로그인 할 때 사용자가 응용 프로그램 내 제품 미결제 소모품을 소유하고있는 경우 그 후, 당신은 확인해야합니다, 그래서 경우, 해당 항목을 소비하고 제공해야합니다. 응용 프로그램에서 소비 인앱 제품을 구현하는 경우 다음은 권장되는 응용 프로그램 시작 흐름은 다음과 같습니다

  1. 사용자의 소유 인앱 제품을 조회 할 getPurchases 요청을 ​​보냅니다.
  2. 응용 제품 소모품을가있는 경우, consumePurchase를 호출하여 항목을 사용합니다. 응용 프로그램이 소모품에 대한 구매 주문을 완료 되었으나, 중지 또는 응용 프로그램이 소비 요청을 보낼 수있는 기회가되기 전에 분리있어 수도 있기 때문에이 단계가 필요합니다.
  3. 소비가 성공적으로 완료 여부를 나타내는 구글 플레이에서 응답 코드를 얻을.
  4. 소비가 성공하면 제공 응용 프로그램의 제품입니다.

Local Caching


구글은 클라이언트가 현재 장치에 로컬로 결제 정보 - 응용 프로그램 캐시 플레이하기 때문에, 당신은 getPurchases 호출을 통해 예를 들어, 더 자주이 정보를 쿼리하는 버전 3 API를 사용할 수 있습니다.API의 이전 버전과는 달리, 여러 버전 3 API 호출이 캐시 조회를 통해 대신 크게 API의 응답 시간을 단축 구글 플레이에 대한 네트워크 연결을 통해 서비스됩니다.


Trackback 0 And Comment 0

유니티 xml 파일 로드

|









xml로 된 데이터 파일은 모두 string 형이므로 적절히 형변환을 해줘서 사용해야됨.

Trackback 0 And Comment 0

두 벡터간의 거리 구하기

|



두 벡터를 빼고난후 Dot를 사용함..

하지만 이미 Vector3.Distance 함수가 있음.


Trackback 0 And Comment 0
prev | 1 | 2 | next