Pro Yearly is on sale from $80 to $50! »

Xamarinアプリとプッシュ通知

 Xamarinアプリとプッシュ通知

2017/06/17(土) 学生でもわかるXamarin勉強会

619fccc61ef955ccf39bfa41df527042?s=128

Nobuhiro Ito

June 17, 2017
Tweet

Transcript

  1. 9BNBSJOΞϓϦͱϓογϡ௨஌ /PCVIJSP*UP ֶੜͰ΋Θ͔Δ9BNBSJOษڧձ

  2. ࣗݾ঺հ w ҏ౻৳༟!JTFFCJ w ϑΣϯϦϧגࣜձࣾΞϓϦέʔγϣϯڞಉ։ൃ෦νʔϑΤϯδχΞ w ݉ɹ৽نࣄۀ෦#PMU[&OHJOFϓϩμΫτΦʔφʔ w ओʹεϚʔτϑΥϯΞϓϦͷઃܭɾ։ൃΛ୲౰ɻ࠷ۙ͸Ϛωʔδϝϯτ΋ɻ w

    J04 4XJGU 0CKFDUJWF$ "OESPJE +BWB 9BNBSJO $ 8FC 1)1
  3. None
  4. ໊ݹ԰ͰΠϕϯτ΍ͬͯ·͢ w .PCJMF"DU/"(0:" w ϑΣϯϦϧ໊ݹ԰ࢧࣾϝϯόʔ͕ओ࠵ w ִ݄͘Β͍Ͱ։࠵த ௚ۙ͸ࡢ೔ʂʂ  w

    IUUQTNPCJMFBDUOBHPZBDPOOQBTTDPN
  5. αϚʔΠϯλʔϯ։࠵༧ఆ w ϓϩδΣΫτݚमͰ࢖ΘΕ͍ͯΔ՝୊Ͱɺ࣮ࡍͷۀ຿ͷྲྀΕΛମݧͰ͖·͢ w ΤϯδχΞ޲͚ w େࡕຊࣾ w ౦ژࢧࣾɾౡࠜࢧࣾɾ໊ݹ԰ࢧࣾ w

    σβΠφʔ޲͚ w େࡕຊࣾɾ౦ژࢧࣾ w ৄࡉ͸དྷिެ։༧ఆ!GFOSJS@SFDSVJUΛϑΥϩʔ͓ئ͍͠·͢ɻ
  6. ϓογϡ௨஌ͱ͸ w Ϣʔβʔ͕ΞϓϦ͔Β཭Ε͍ͯͯ΋ɺ
 ୺຤ɾϒϥ΢β΁ϝοηʔδͳͲͷ௨஌ΛૹΔ࢓૊Έͷ͜ͱɻ
 ৽ண৘ใɾߋ৽৘ใͳͲΛϢʔβʔʹఏڙ͢Δ͜ͱ͕Ͱ͖Δɻ w λΠϚʔɾδΦϑΣϯεͰΞϓϦ୯ମͰ׬݁͢ΔʮϩʔΧϧϓογϡʯͱ
 αʔόʔ͔ΒαʔϏεఏڙऀଆ͕ૹ৴͢ΔʮϦϞʔτϓογϡʯ͕͋Δ w ʮϓογϡ௨஌ʯͱ͍͏ͱϦϞʔτϓογϡͷ͜ͱΛݴͬͯΔ৔߹͕ଟ͍ɻ


    ͜ͷൃදͰ΋جຊతʹϦϞʔτϓογϡͷ͜ͱΛࢦ͠·͢ɻ
  7. ϓογϡ௨஌ͷॏཁੑ w ϢʔβʔʹՁ஋ͷ͋Δ৘ใΛଈ࣌ʹಧ͚Δ͜ͱ͕Ͱ͖Δ w ΞϓϦΛϢʔβʔʹ࢖ͬͯ΋Β͏श׳͚ͮΛ͢Δ͜ͱ͕Ͱ͖Δ w ϓογϡ௨஌ΛڐՄͨ͠ΞϓϦ͸ىಈճ਺΍ܧଓ཰͕ߴ͘ͳΔ ࢀߟΞϓϦϢʔβʔΛΞΫςΟϒʹ͢Δʂઐ໳Ո͕ڭ͑Δʮϓογϡ௨஌ʯͭͷਅ࣮ͱؒҧ͍ɻ%$3ΞϓϦηϛφʔ IUUQBQQNBSLFUJOHMBCPOFUQVTIMJWFQBTT

  8. ϓογϡ௨஌ͷ͘͠Έ "1/T'$. αʔϏεఏڙऀͷ αʔόʔ ΞϓϦ

  9. ϓογϡ௨஌ͷ͘͠Έ "1/T'$. αʔϏεఏڙऀͷ αʔόʔ ΞϓϦ τʔΫϯཁٻ

  10. ϓογϡ௨஌ͷ͘͠Έ "1/T'$. αʔϏεఏڙऀͷ αʔόʔ ΞϓϦ τʔΫϯཁٻ τʔΫϯฦ٫

  11. ϓογϡ௨஌ͷ͘͠Έ "1/T'$. αʔϏεఏڙऀͷ αʔόʔ ΞϓϦ τʔΫϯཁٻ τʔΫϯฦ٫ τʔΫϯొ࿥

  12. ϓογϡ௨஌ͷ͘͠Έ "1/T'$. αʔϏεఏڙऀͷ αʔόʔ ΞϓϦ

  13. ϓογϡ௨஌ͷ͘͠Έ "1/T'$. αʔϏεఏڙऀͷ αʔόʔ ΞϓϦ ϝοηʔδૹ৴ ೝূʴτʔΫϯʴϝοηʔδ

  14. ϓογϡ௨஌ͷ͘͠Έ "1/T'$. αʔϏεఏڙऀͷ αʔόʔ ΞϓϦ ϝοηʔδૹ৴ ೝূʴτʔΫϯʴϝοηʔδ ϝοηʔδ഑৴

  15. ϓογϡ௨஌ͷ͘͠Έ "1/T'$. αʔϏεఏڙऀͷ αʔόʔ ΞϓϦ ϝοηʔδૹ৴ ೝূʴτʔΫϯʴϝοηʔδ ϝοηʔδ഑৴ ʂ ϝοηʔδ͕ಧ͖·ͨ͠

  16. J04Ͱͷϓογϡ௨஌࣮૷

  17. "QQMF΁ͷొ࿥ w "QQMF%FWFMPQFS1SPHSBN΁
 "QQ*%Λొ࿥͢Δඞཁ͕͋Δ w "QQ*%ͷొ࿥ w "1/Tূ໌ॻͷൃߦ w ϓϩϑΝΠϧͷ࡞੒

  18. "QQ*%ͷొ࿥

  19. "QQ*%ͷొ࿥

  20. "QQ*%ͷొ࿥

  21. "1/Tূ໌ॻͷൃߦ w "QQ*%ొ࿥ޙͷը໘ʹදࣔ͞ΕΔ w ϏϧυʹΑͬͯ࢖͏ূ໌ॻ͕ҟͳΓɺ઀ଓઌ΋ҟͳΔ w %FCVHϏϧυ࣌ɺ4BOECPY w 3FMFBTFϏϧυ࣌ɺ1SPEVDUJPO

  22. ৄ͘͠͸ w #PMU[&OHJOFαϙʔτϖʔδΛ͝ཡ͍ͩ͘͞ w "1/TΛ࢖͏J04ΞϓϦͷϏϧυʹඞཁͳܖ໿ɾ֤छূ໌ॻͷ४උΛ͢Δʹ ͸
 IUUQTXXXGFOSJSJODDPNKQCPMU[FOHJOFTVQQPSUJPT@DFSUJpDBUFT

  23. ࣮૷ w 04όʔδϣϯ͝ͱʹҟͳΔ จݙͷࢀߟ࣌ʹ஫ҙʂ  w J04·Ͱ͸ɺϦϞʔτϓογϡͷొ࿥ͷΈ ड৴छผͷొ࿥΋͢Δ  w

    UIApplication.SharedApplication.RegisterForRemoteNotificationTypes w J04Ҏ߱͸ɺ௨஌ͷڐՄͱϦϞʔτϓογϡͷొ࿥͕෼͔Εͨ w UIApplication.SharedApplication.RegisterUserNotificationSettings w UIApplication.SharedApplication.RegisterForRemoteNotification w J04Ҏ߱ɺ6TFS/PUJpDBUJPO'SBNFXPSLʹ෼཭͞Εͨ w UNUserNotificationCenter.Current.RequestAuthorization w UIApplication.SharedApplication.RegisterForRemoteNotification
  24. ͱ͍͏͜ͱ͸ w 04όʔδϣϯ͝ͱʹ࢖༻͢Δํ๏Λ࢖͍෼͚Δඞཁ͕͋Δ w ࢖͍ͬͯΔ04Ͱ࣮૷͞Ε͍ͯͳ͍"1*ୟ͘ͱΫϥογϡ w J04Ҏ߱ʹͰ͖ͨΒ࠷ߴ w J04͸͕͢͞ʹ΋͏ͳ͍Ͱ͠ΐ͏ɻ w

    J04ͱJ04ͷڞଘ͸ݱஈ֊Ͱ͸͔͕ͨ͠ͳ͍৔໘ଟͦ͏ UIDevice.CurrentDevice.CheckSystemVersionͰνΣοΫ͢Δ΄͔ͳ͠

  25. private async void RequestPushNotificationAuthorization()
 {
 if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
 {
 var

    result = await UNUserNotificationCenter.Current.RequestAuthorizationAsync(
 UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound);
 if (result.Item1)
 {
 UIApplication.SharedApplication.RegisterForRemoteNotifications();
 }
 }
 else
 {
 var settings = UIUserNotificationSettings.GetSettingsForTypes(
 UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null);
 UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
 }
 }
 
 public override void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
 {
 UIApplication.SharedApplication.RegisterForRemoteNotifications();
 }

  26. public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
 {
 var tokenString

    = BitConverter.ToString(deviceToken.ToArray()).Replace("-", "");
 Console.WriteLine(tokenString);
 
 // ダメ絶対
 // tokenString = deviceToken.ToString().Replace(" ", "");
 } w NSData.ToString͸- (NSString *) descriptionʹϚοϓ͞Ε͍ͯΔ w ͜ͷϝιου͸σόοά༻Ͱग़ྗ͸ෆఆͱ͞Ε͍ͯΔ কདྷมΘΔՄೳੑ΋ඍϨଘ  w ҰํBitConverter.ToString͸AA-BB-CC-00-12-34…ͱ͍͏ܗࣜͰ͋Δͱ
 ϦϑΝϨϯεͰ໌ࣔ͞Ε͍ͯΔ ͜Ε͕ϓογϡτʔΫϯͩʂ
  27. "OESPJEͰͷϓογϡ௨஌࣮૷

  28. 'JSFCBTFͷొ࿥ w 'JSFCBTFͰ4FOEFS*%ͱ4FSWFS"1*,FZΛ࡞Δ w IUUQTDPOTPMFpSFCBTFHPPHMFDPN

  29. 'JSFCBTFͷొ࿥

  30. 'JSFCBTFͷొ࿥

  31. 'JSFCBTFͷొ࿥

  32. 'JSFCBTFͷొ࿥

  33. 'JSFCBTFͷొ࿥

  34. 'JSFCBTFͷొ࿥

  35. /V(FUύοέʔδͷಋೖ w ҎԼͷ/V(FUύοέʔδΛಋೖ͢Δ w 9BNBSJO(PPHMF1MBZ4FSWJDFT#BTF w 9BNBSJO'JSFCBTF.FTTBHJOH w 'JSFCBTFͷઃఆதʹ࡞੒͞Εͨ
 HPPHMFTFSWJDFTKTPOΛϓϩδΣΫτʹ௥Ճ


    ϏϧυΞΫγϣϯΛ
 (PPHMF4FSWJDFT+TPOʹมߋ w ग़ͯ͜ͳ͔ͬͨΒ74.BD࠶ىಈ
  36. (PPHMF1MBZ4FSWJDFͷ൑ఆ public bool IsPlayServicesAvailable()
 {
 int resultCode = GoogleApiAvailability.Instance.IsGooglePlayServicesAvailable(this);
 if

    (resultCode == ConnectionResult.Success)
 {
 return true;
 }
 
 if (GoogleApiAvailability.Instance.IsUserResolvableError(resultCode))
 {
 // ユーザーの操作によって解決できる問題の場合 (Google Play 開発者サービスが古いなど)
 return false;
 }
 else 
 {
 // Google Play 開発者サービスが入っていない端末の場合
 return false;
 }
 }
  37. τʔΫϯͷऔಘ button.Click += delegate
 {
 if (IsPlayServicesAvailable()) 
 {
 Log.Debug("PushNotificationSample",

    $"Push Token is {FirebaseInstanceId.Instance.Token} ");
 }
 }; ͜Ε͕ϓογϡτʔΫϯͩʂ w ࣮ࡍ͸*T1MBZ4FSWJDF"WBJMBCMFͷ൑ఆͰ
 Ϣʔβʔʹ։ൃऀαʔϏεͷߋ৽Λଅͨ͠ΓɺΞϓϦΛڧ੍ऴྃͨ͠Γ͢Δ
  38. *OTUBODF*%3FDFJWFSͷొ࿥ w "OESPJEͷϓογϡτʔΫϯ͸ಥવมΘΔ৔߹͕͋Δ w τʔΫϯͷมߋΛड৴͢ΔαʔϏεΛΞϓϦʹొ࿥͓͔ͯ͠ͳ͚Ε͹ͳΒͳ͍ w "OESPJE.BOJGFTUʹهࡌ <application …>
 <receiver

    android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
 <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" 
 android:exported="true" 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="${applicationId}" />
 </intent-filter>
 </receiver>
 </application>
  39. *OTUBODF*%4FSWJDFͷ࣮૷ [Service]
 [IntentFilter(new[] { "com.google.firebase.INSTANCE_ID_EVENT" })]
 public class AppInstanceIdService :

    FirebaseInstanceIdService
 {
 public override void OnTokenRefresh()
 {
 var refreshedToken = FirebaseInstanceId.Instance.Token;
 Log.Debug(Log.Debug("PushNotificationSample", $"Push Token is {FirebaseInstanceId.Instance.Token}");
 }
 }
 ϓογϡτʔΫϯ͕ߋ৽͞ΕΔͱ௨஌͞ΕΔ
  40. ௨஌ͷૹ৴

  41. ϥΠϒϥϦͷબఆ w ϓογϡͷ"1*ͬͯΘΓͱ΍΍͍͜͠ɻ
 αʔόʔαΠυʹͲΜͳݴޠΛ࢖͏͔ͰมΘͬͯ͘Δɻ w $Λ࢖͏ͳΒ1VTI4IBSQͱ͍͏બ୒ࢶ͔ɻ w IUUQTHJUIVCDPN3FEUI1VTI4IBSQ w ݴޠ

    "1/T($.Ͱݕࡧͯ͠ΈΑ͏ w 'JSFCBTF΂ͬͨΓʹͳΔͳΒɺ'JSFCBTFͷ؅ཧը໘Ͱ΍Δͱ͍͏ͷ΋ҰҊ
  42. 1VTI4IBSQΛ࢖ͬͨૹ৴ IUUQTHJUIVCDPN3FEUI1VTI4IBSQTBNQMFVTBHF

  43. 

  44. None
  45. #PMU[&OHJOFͰૹͬͯΈΑ͏ ༗ঈ੡඼ͳΜͰͪΐͬͱਃ͠༁ͳ͍Ͱ͕͢ʜ

  46. ͦ΋ͦ΋#PMU[&OHJOF͸ w ௒ߴ଎ϓογϡ௨஌Τϯδϯ w ඵؒສσόΠε ࠃ಺࠷଎Ϋϥε  w େྔɾߴ଎ͷ഑৴ཁ݅ʹద߹ w

    ύοέʔδλΠϓ w ϓϥΠϕʔτΫϥ΢υɾΦϯϓϨϛεͳͲ΁ͷల։ w ηΩϡϦςΟϙϦγʔతʹ"41΍"[VSFΛબ୒Ͱ͖ͳ͍৔߹ w εϚʔτϑΥϯ޲͚ "1/T($. ΢Σϒϒϥ΢β޲͚ͷૹ৴ʹରԠ
  47. IUUQTXXXGFOSJSJODDPNKQCPMU[FOHJOF

  48. #PMU[&OHJOF΁ͷ઀ଓ w #PMU[&OHJOFຊମ͸ૹ৴ͷΈΛ୲౰ɻ഑৴؅ཧ͸ผ్༻ҙ͠·͢ɻ w ಠࣗ։ൃ͢Δ৔߹͸H31$)551$47ͳͲͰૹ৴Մೳ

  49. ඪ४ͷ഑৴؅ཧػೳ ඪ४ͷ഑৴؅ཧػೳɾϦϑΝϨϯε࣮૷ͱͯ͠#PMU[.FTTFOHFSΛ༻ҙ

  50. #PMU[&OHJOF΁ͷ઀ଓ w #PMU[&OHJOFຊମ͸ૹ৴ͷΈΛ୲౰ɻ഑৴؅ཧ͸ผ్༻ҙ͠·͢ɻ w ಠࣗ։ൃ͢Δ৔߹͸H31$)551$47ͳͲͰૹ৴Մೳ

  51. #PMU[&OHJOF΁ͷ઀ଓ w #PMU[&OHJOFຊମ͸ૹ৴ͷΈΛ୲౰ɻ഑৴؅ཧ͸ผ్༻ҙ͠·͢ɻ w ಠࣗ։ൃ͢Δ৔߹͸H31$)551$47ͳͲͰૹ৴Մೳ

  52. None
  53. H31$ w (PPHMF͕ެ։ͨ͠(PPHMF಺Ͱ΋࢖ΘΕ͍ͯΔ31$ϑϨʔϜϫʔΫ w 1SPUPDPM#V⒎FS͔Β֤ݴޠ޲͚ͷϥΠϒϥϦΛੜ੒͢ΔͷͰɺ
 ༷ʑͳݴޠ͔Β઀ଓͰ͖Δ w )551͕࢖ΘΕ͍ͯΔ w #PMU[&OHJOFͰ͸೥݄ͷ͔ΒରԠ

    w ͦΕ·Ͱͷ(PͷOFUSQDʹ୅ΘΓඪ४"1*ͱͳΓͭͭ͋Δ w #PMU[&OHJOF΁ͷ઀ଓ͸(P +BWB4DSJQU 3VCZ $Ͱ࣮੷͋Γ
  54. $ͰH31$Λ࢖͏ w QSPUPϑΝΠϧͷม׵ w /V(FUύοέʔδͷΠϯετʔϧ w ίʔυͷهड़ w ࠓͷͱ͜Ζ9BNBSJO.BD͸μϝͦ͏ɻ/&5'SBNFXPSL͕͍͍͔ͱɻ

  55. QSPUPϑΝΠϧͷม׵ w #PMU[&OHJOFఴ෇ͷQSPUPϑΝΠϧΛ·ͱΊΔ w /V(FU͔Β(SQD5PPMTΛμ΢ϯϩʔυ͢Δ
 /V(FU͔ΒOVQLHམͱ͖ͯͯ͠VO[JQʜ $ temp_dir=packages/Grpc.Tools.1.3.6/tmp $ curl_url=https://www.nuget.org/api/v2/package/Grpc.Tools/

    $ mkdir -p $temp_dir && cd $temp_dir && curl -sL $curl_url > tmp.zip; unzip tmp.zip \
 && cd .. && cp -r tmp/tools . && rm -rf tmp && cd ../.. $ chmod +x packages/Grpc.Tools.1.3.6/tools/macosx_x64/protoc $ chmod +x packages/Grpc.Tools.1.3.6/tools/macosx_x64/grpc_csharp_plugin
  56. QSPUPϑΝΠϧͷม׵ w ҎԼͷΑ͏ͳίϚϯυͰม׵ w QSPUPσΟϨΫτϦʹೖ͍ͬͯΔ΋ͷΛ#PMU[&OHJOF3QDϑΥϧμʹల։ $ mkdir BoltzEngine.Rpc $ packages/Grpc.Tools.1.3.6/tools/macosx_x64/protoc

    \ --plugin=protoc-gen-grpc=packages/Grpc.Tools.1.3.6/tools/macosx_x64/grpc_csharp_plugin --csharp_out BoltzEngine.Rpc --grpc_out BoltzEngine.Rpc \
 -Iprotos protos/*.proto
  57. /V(FUύοέʔδͷΠϯετʔϧ w ϓϩδΣΫτʹҎԼͷ/V(FUύοέʔδΛΠϯετʔϧ w (SQD w (PPHMF1SPUPCVG w QSPUPϑΝΠϧ͔Βม׵ͨ͠DTϑΝΠϧ΋௥Ճ͢Δ

  58. #PMU[&OHJOFͰͷ௨஌ૹ৴ w $IBOOFMΫϥεͷΠϯελϯεΛੜ੒ w #PMU[(BUFXBZ$MJFOUΛੜ੒ w .FTTBHFΛੜ੒ w 4FOEͰૹ৴ w

    ࣦഊ৘ใɾτʔΫϯมߋ৘ใΛ4USFBN͔Βऔಘ var channel = new Channel("boltzengine.example.com:13009", ChannelCredentials.Insecure);
 var client = new BoltzGateway.BoltzGatewayClient(channel);
  59. ϝοηʔδͷ࡞੒ ϔομ var cert = File.ReadAllText("cert.pem");
 var key = File.ReadAllText("key.pem");


    
 var message = new Message
 {
 ApnsHeader = new BoltzEngine.Rpc.Apns.Header()
 {
 Address = "gateway.push.apple.com:2195",
 KeyPEMBlock = Google.Protobuf.ByteString.CopyFromUtf8(key),
 CertPEMBlock = Google.Protobuf.ByteString.CopyFromUtf8(cert),
 },
 GcmHeader = new BoltzEngine.Rpc.Gcm.Header() 
 {
 RequestURL = "https://fcm.googleapis.com/fcm/send",
 ServerKey = “AAAAw…”,
 SenderID = "825337918540",
 },
 Priority = Priority.High,
 BandWidth = 0
 } ;

  60. ϝοηʔδͷ࡞੒ ϔομ var cert = File.ReadAllText("cert.pem");
 var key = File.ReadAllText("key.pem");


    
 var message = new Message
 {
 ApnsHeader = new BoltzEngine.Rpc.Apns.Header()
 {
 Address = "gateway.push.apple.com:2195",
 KeyPEMBlock = Google.Protobuf.ByteString.CopyFromUtf8(key),
 CertPEMBlock = Google.Protobuf.ByteString.CopyFromUtf8(cert),
 },
 GcmHeader = new BoltzEngine.Rpc.Gcm.Header() 
 {
 RequestURL = "https://fcm.googleapis.com/fcm/send",
 ServerKey = “AAAAw…”,
 SenderID = "825337918540",
 },
 Priority = Priority.High,
 BandWidth = 0
 } ;
 "1/Tൿີ伴ͱূ໌ॻΛಡΈࠐΈ #ZUF4USJOHͰࢦఆ
  61. ϝοηʔδͷ࡞੒ ϔομ var cert = File.ReadAllText("cert.pem");
 var key = File.ReadAllText("key.pem");


    
 var message = new Message
 {
 ApnsHeader = new BoltzEngine.Rpc.Apns.Header()
 {
 Address = "gateway.push.apple.com:2195",
 KeyPEMBlock = Google.Protobuf.ByteString.CopyFromUtf8(key),
 CertPEMBlock = Google.Protobuf.ByteString.CopyFromUtf8(cert),
 },
 GcmHeader = new BoltzEngine.Rpc.Gcm.Header() 
 {
 RequestURL = "https://fcm.googleapis.com/fcm/send",
 ServerKey = “AAAAw…”,
 SenderID = "825337918540",
 },
 Priority = Priority.High,
 BandWidth = 0
 } ;
 "1/Tͷήʔτ΢ΣΠαʔόʔ 4BOECPYͷ৔߹͸HBUFXBZTBOECPYQVTIBQQMFDPN
  62. ϝοηʔδͷ࡞੒ ϔομ var cert = File.ReadAllText("cert.pem");
 var key = File.ReadAllText("key.pem");


    
 var message = new Message
 {
 ApnsHeader = new BoltzEngine.Rpc.Apns.Header()
 {
 Address = "gateway.push.apple.com:2195",
 KeyPEMBlock = Google.Protobuf.ByteString.CopyFromUtf8(key),
 CertPEMBlock = Google.Protobuf.ByteString.CopyFromUtf8(cert),
 },
 GcmHeader = new BoltzEngine.Rpc.Gcm.Header() 
 {
 RequestURL = "https://fcm.googleapis.com/fcm/send",
 ServerKey = “AAAAw…”,
 SenderID = "825337918540",
 },
 Priority = Priority.High,
 BandWidth = 0
 } ;
 '$.ͷ"1*Ωʔͱૹ৴ऀ*%Λࢦఆ
  63. ϝοηʔδͷ࡞੒ ಺༰ message.Payload = @"{""aps"":{""alert"":""Hello Hello""}}";
 message.Parameters = new BoltzEngine.Rpc.Gcm.Parameters();


    message.Parameters.Notification.Add("title", "Hello Hello"); w #PMU[&OHJOFH31$͸ͭͷϝοηʔδͰෳ਺ͷαʔϏεʹૹ৴Մೳ w J04͸1BZMPBE "OESPJE͸1BSBNFUFST 8FC1VTI͸#PEZʹࢦఆ
  64. ϝοηʔδͷ࡞੒ ૹΓઌ w ֤ϓϥοτϑΥʔϜͷτʔΫϯͷલʹɺ਺ࣈΛ݁߹ͯ͠౉͢ w #PMU[&OHJOFH31$ͷ࢓্༷ඞཁͳૢ࡞ͰɺଞͷϥΠϒϥϦΛ࢖͏࣌͸ෆཁ w J04͸ "OESPJE͸ 8FC1VTI͸

    message.Tokens.Add("1" + “126ae202b2d51…");
 message.Tokens.Add("2" + “cTSHJ6XaN4Y:APA91bH…");
  65. ϝοηʔδͷૹ৴ var streamingCall = client.Send(message);
 
 while (await streamingCall.ResponseStream.MoveNext(CancellationToken.None))
 {


    var ev = streamingCall.ResponseStream.Current;
 switch (ev.EventCase)
 {
 case Event.EventOneofCase.Failed:
 Console.WriteLine($"Failed: {ev.Failed.Token} reason: {ev.Failed.Kind} ");
 break;
 case Event.EventOneofCase.Renewed:
 Console.WriteLine($"Renewed: {ev.Renewed.RecentToken} to {ev.Renewed.LatestToken} ");
 break;
 }
 }
  66. ࠓճ͓࿩͠͠ͳ͔ͬͨ͜ͱ w αʔόʔ্ͰͷτʔΫϯͷऔΓѻ͍ w ແޮɾߋ৽τʔΫϯͷऔΓѻ͍ w ίϯςϯπ෇͖ϓογϡ w ϓογϡΛτϦΨʔͨ͠σʔλߋ৽ɾόοΫάϥ΢ϯυಈ࡞ w

  67. ϓογϡ௨஌ͷ࢓૊ΈΛ
 ཧղ͢ΔͱΑΓ׆༻Ͱ͖·͢ ϓογϡ௨஌Λ༗ޮʹར༻ͯ͠ ΞϓϦΛΑΓັྗతʹ͠·͠ΐ͏

  68. ࢀߟ

  69. 04͝ͱͷϓογϡ௨஌ͷࠩ J04 "OESPJE 8FC ڐՄཁٻ τʔΫϯͷऔಘ࣌ʹ
 ڐՄμΠΞϩά σϑΥϧτͰڐՄ τʔΫϯ͸ඞͣऔΕΔ τʔΫϯͷऔಘ࣌ʹ


    ڐՄμΠΞϩά αʔόʔͷೝূɾొ࿥ "%1Ͱূ໌ॻൃߦ 'JSFCBTFͰΩʔൃߦ ࣗ෼Ͱ҉߸ԽΩʔΛੜ੒ ௨஌ͷ಺༰ ϑΥʔϚοτʹܾ·Γ͋Γ +40/ܗࣜ ,FZ7BMVFͰ౉͢ ೚ҙͷςΩετ +40/Λྲྀ͢ͷ͕࣮༻త ௨஌ΛτϦΨʔͱͨ͠ಈ࡞ ϑϥάΛཱͯΔͱՄೳ ൃಈ͸ෆ҆ఆ Մೳ Մೳ ୺຤ͷ௨஌දࣔ΋ΞϓϦଆͰ࣮૷ ແޮ୺຤ͷॲཧ ϑΟʔυόοΫαʔϏε΁ ఆظతʹݟʹߦ͘ ૹ৴࣌ʹ൑໌͢Δ ૹ৴࣌ʹ൑໌͢Δ