それが可能かどうかはわかりませんが、ユーザーの許可を求めた後、私のアプリは、自分のアプリを介して携帯電話でフォーマットされた SMS を送信したいと考えています。SMS入力画面を表示せずにバックグラウンドで発生させたいのですが、送信されたSMSがメッセージリストに表示されず、フォーマットされた受信メッセージのみが表示されるようにします。
それは可能ですか?最初はiPhoneに実装したいと思っていますが、後でAndroidとwp7に拡張したいと考えています。前もって感謝します。
それが可能かどうかはわかりませんが、ユーザーの許可を求めた後、私のアプリは、自分のアプリを介して携帯電話でフォーマットされた SMS を送信したいと考えています。SMS入力画面を表示せずにバックグラウンドで発生させたいのですが、送信されたSMSがメッセージリストに表示されず、フォーマットされた受信メッセージのみが表示されるようにします。
それは可能ですか?最初はiPhoneに実装したいと思っていますが、後でAndroidとwp7に拡張したいと考えています。前もって感謝します。
iOSでは、できません。
ただし、サードパーティのサービスを使用することもできます。
他のプラットフォームについてはわかりませんが、iOSでは、アプリがSMSを送信する場合、ユーザーの許可を求められ、ユーザーはSMSインターフェイスに移動します。Appleはこれらについて非常に厳格ですが、Androidではこれが可能かもしれません。
編集:あなたが何をしようとしているのかわかりませんが、なぜウェブを使用しないのですか?ユーザーがコンテンツや宛先を知らないというメッセージを送信しようとしている場合は、SMSで送信する必要はありません。
私が考えることができる唯一の代替手段は、SMS ゲートウェイを提供する Web サービスに NSHTTPURLRequest を送信することです。バックグラウンドで行うことは確かに可能ですが、おそらくあなた (ユーザーではなく開発者) がメッセージの送信コストを負担し、送信者がユーザーではないように見えます。
次のようにバックグラウンドで SMS を送信できます。
ここでは、ボタンのクリックを使用して、ユーザーの前に画面が表示されずにバックグラウンドで SMS を送信できます。(注 :該当する場合は戻り、それ以外の場合は空の値を返します。)
所有者の電話番号を取得:
TelephonyManager tMgr =(TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String number = tMgr.getLine1Number();
Pending Intent
クリックイベントでこのコードを書き込みます。
String message = "HI THIS IS TEST SMS IN ANDROID.";
/** Creating a pending intent which will be broadcasted when an sms message is successfully sent */
PendingIntent piSent = PendingIntent.getBroadcast(getBaseContext(), 0, new Intent("sent_msg") , 0);
/** Creating a pending intent which will be broadcasted when an sms message is successfully delivered */
PendingIntent piDelivered = PendingIntent.getBroadcast(getBaseContext(), 0, new Intent("delivered_msg"), 0);
/** Getting an instance of SmsManager to sent sms message from the application*/
SmsManager smsManager = SmsManager.getDefault();
/** Sending the Sms message to the intended party */
smsManager.sendTextMessage(number, null, message, piSent, piDelivered);
クラス名を作成SmsNotifications
するextends BroadcastReceiver
/**
* This class handles the SMS sent and sms delivery broadcast intents
*/
public class SmsNotifications extends BroadcastReceiver{
/**
* This method will be invoked when the sms sent or sms delivery broadcast intent is received
*/
@Override
public void onReceive(Context context, Intent intent) {
/**
* Getting the intent action name to identify the broadcast intent ( whether sms sent or sms delivery )
*/
String actionName = intent.getAction();
if(actionName.equals("sent_msg")){
switch(getResultCode()){
case Activity.RESULT_OK:
Toast.makeText(context, "Message is sent successfully" , Toast.LENGTH_SHORT).show();
break;
default:
Toast.makeText(context, "Error in sending Message", Toast.LENGTH_SHORT).show();
break;
}
}
if(actionName.equals("delivered_msg")){
switch(getResultCode()){
case Activity.RESULT_OK:
Toast.makeText(context, "Message is delivered" , Toast.LENGTH_SHORT).show();
break;
default:
Toast.makeText(context, "Error in the delivery of message", Toast.LENGTH_SHORT).show();
break;
}
}
}
}
マニフェスト ファイルを管理します。
許可 :
<uses-permission android:name="android.permission.SEND_SMS" />
と
<receiver android:name=".SmsNotifications" >
<intent-filter >
<action android:name="sent_msg" />
<action android:name="delivered_msg" />
</intent-filter>
</receiver>
SmsComposeTask
Windows Phone 7 ではこれを行うことができませんMFMessageComposeViewController
。これは、すべてのテキスト送信ロジックがそこで処理され、一部のパラメーターのみを調整できることを意味します。