Intégration de la bibliothèque Xamarin
1. Modifiez le framework cible de votre projet Android pour Android 8.0 ou une version ultérieure.
2. Ajoutez le paquet nuget Pushwoosh aux projets Android et iOS.
3. Apportez les modifications suivantes dans le fichier AppDelegate.cs de votre projet iOS :
3.1. Au début de la méthode FinishedLaunching
, insérez la ligne suivante :
Pushwoosh.iOS.PushManager.Init();
3.2. Ajoutez ces méthodes à l’AppDelegate :
public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken){ Pushwoosh.iOS.PushManager.Instance.RegisteredForRemoteNotifications(deviceToken);}
public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error){ Pushwoosh.iOS.PushManager.Instance.FailedToRegisterForRemoteNotifications(error);}
public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo){ Pushwoosh.iOS.PushManager.Instance.ReceivedRemoteNotification(userInfo);}
4. Dans le fichier Info.plist, remplacez la valeur Pushwoosh_APPID par votre Application Code Pushwoosh. Vous pouvez le trouver dans votre Control Panel.
5. Configurez votre projet dans la console Firebase.
6.1. Ajoutez le fichier google-services.json
à votre projet Android.
6.2. Dans Visual Studio, faites un clic droit sur google-services.json
et choisissez l’option GoogleServicesJson dans le menu Build Action.
7. Dans le fichier MainActivity.cs de votre projet Android, avant de définir l’espace de noms, ajoutez ces lignes :
[assembly:MetaData("com.pushwoosh.appid", Value = "YOUR_PUSHWOOSH_APP_CODE")][assembly:MetaData("com.pushwoosh.senderid", Value = "@string/fcm_sender_id")]
De plus, au début de la méthode onCreate
de la classe MainActivity, initialisez le PushManager avec la ligne Pushwoosh.Droid.PushManager.Init();
.
8. Dans votre projet Android, trouvez le fichier Resources/values/strings.xml ou créez-le. Ajoutez-y votre chaîne Sender ID :
<string name="fcm_sender_id">YOUR_SENDER_ID</string>
9. Dans la partie multiplateforme de App.xaml.cs, ajoutez l’enregistrement à la méthode onStart
:
PushManager.Instance.Register();
Message Inbox
Anchor link to1. Installez le paquet nuget Pushwoosh.Inbox dans vos projets.
2.1. Pour iOS, ajoutez la ligne suivante à votre fichier AppDelegate.cs (après Pushwoosh.iOS.PushManager.Init();
) :
Pushwoosh.Inbox.iOS.InboxManager.Init();
2.2. Pour Android, ajoutez la ligne suivante à votre fichier MainActivity.cs (après Pushwoosh.Droid.PushManager.Init();
) :
Pushwoosh.Inbox.Droid.InboxManager.Init();
3. Pour afficher l’interface utilisateur de l’Inbox dans votre application :
3.1. Créez l’instance PushwooshInboxStyle :
PushwooshInboxStyle inboxStyle = new PushwooshInboxStyle{ AccentColor = Color.Violet, BackgroundColor = Color.White, BarAccentColor = Color.Blue, BarBackgroundColor = Color.WhiteSmoke, BarTextColor = Color.DarkGray, DateColor = Color.Violet, DefaultTextColor = Color.DarkBlue, DescriptionColor = Color.DarkBlue, SelectionColor = Color.Crimson, SeparatorColor = Color.Crimson, TitleColor = Color.DarkKhaki,
DefaultImageName = "inbox_message", ListEmptyImageName = "inbox_empty", ListErrorImageName = "inbox_error", UnreadImageName = "inbox_unread",
BarTitle = "Mon titre personnalisé", ListEmptyMessage = "Il n'y a pas encore de message dans la boîte de réception", ListErrorMessage = "Une erreur est survenue",
DateFormat = "dd.MM.yyyy"};
3.2. Ensuite, appelez :
InboxManager.Instance.PresentInboxUI(inboxStyle);
Partagez vos commentaires avec nous
Anchor link toVos commentaires nous aident à créer une meilleure expérience, nous serions donc ravis de connaître votre avis si vous rencontrez des problèmes lors du processus d’intégration du SDK. Si vous rencontrez des difficultés, n’hésitez pas à nous faire part de vos réflexions via ce formulaire.