Exemplo n.º 1
0
    /**
     * Called when Pushe is registered.
     */
    private void OnPusheRegisteredSuccessfully()
    {
        PusheUnity.Log(" --- Pushe has been REGISTERED to server successfully --- ");
        var adId = PusheUnity.GetAdvertisingId();

        PusheUnity.Log("Ad id: " + adId);
        var deviceId = PusheUnity.GetDeviceId();

        PusheUnity.Log("Device id : " + deviceId);

        // Pushe Notification

        PusheUnity.Log("Notification enabled? " + PusheNotification.IsNotificationEnabled());
        PusheUnity.Log("Custom sound enabled? " + PusheNotification.IsCustomSoundEnabled());
        PusheNotification.CreateNotificationChannel("CustomChannel", "CustomChannel");

        // Analytics
        PusheAnalytics.SendEvent("Some_Event");
        PusheAnalytics.SendEcommerceData("EcommerceData", 12.0);

        PusheUnity.Log("Subscribing to test1");
        PusheUnity.Subscribe("test1");

        PusheUnity.Log("Set 123123 as custom id");
        PusheUnity.SetCustomId("123123");
        PusheUnity.Log("CustomId is: " + PusheUnity.GetCustomId());

        var tags = new Dictionary <string, string> {
            { "name", "Mohammad" }, { "age", "25" }, { "birthday", "1435187386" }
        };

        PusheUnity.AddTags(tags);

        PusheUnity.RemoveTags("name", "age");

        PusheUnity.Log("Tags: " + PusheUnity.GetSubscribedTags());
        PusheUnity.Log("Topics: " + string.Join(",", PusheUnity.GetSubscribedTopics()));

        PusheInAppMessaging.DisableInAppMessaging();
        PusheUnity.Log("Is in app messaging enabled?" + PusheInAppMessaging.IsInAppMessagingEnabled());
        PusheInAppMessaging.EnableInAppMessaging();
        PusheUnity.Log("Is in app messaging enabled? " + PusheInAppMessaging.IsInAppMessagingEnabled());
        PusheInAppMessaging.TriggerEvent("qqq");
        PusheInAppMessaging.SetInAppMessagingListener(new InAppMessagingListener());
    }
Exemplo n.º 2
0
    /**
     * Called when Pushe is registered.
     */
    private void OnPusheRegisteredSuccessfully()
    {
        PusheUnity.Log(" --- Pushe has been REGISTERED to server successfully --- ");
        var adId = PusheUnity.GetAdvertisingId();

        PusheUnity.Log("Ad id: " + adId);
        var deviceId = PusheUnity.GetDeviceId();

        PusheUnity.Log("Device id : " + deviceId);

        // Pushe Notification

        PusheUnity.Log("Notification enabled? " + PusheNotification.IsNotificationEnabled());
        PusheUnity.Log("Custom sound enabled? " + PusheNotification.IsCustomSoundEnabled());
        // PusheNotification.CreateNotificationChannel("CustomChannel", "CustomChannel");
        PusheUnity.Log("Sending d2d");
        PusheNotification.SendNotificationToUser(UserNotification.WithDeviceId(PusheUnity.GetDeviceId()).SetTitle("Title").SetContent("Content"));
        // Analytics
        PusheAnalytics.SendEvent("Some_Event");
        PusheAnalytics.SendEcommerceData("EcommerceData", 12.0);

        PusheUnity.Log("Subscribing to test1");
        PusheUnity.Subscribe("test1");

        PusheUnity.Log("Set 123123 as custom id");
        PusheUnity.SetCustomId("123123");
        PusheUnity.Log("CustomId is: " + PusheUnity.GetCustomId());

        var tags = new Dictionary <string, string> {
            { "name", "Mohammad" }, { "age", "25" }, { "birthday", "1435187386" }
        };

        PusheUnity.AddTags(tags);

        PusheUnity.RemoveTags("name", "age");

        PusheUnity.Log("Tags: " + PusheUnity.GetSubscribedTags());
        PusheUnity.Log("Topics: " + string.Join(",", PusheUnity.GetSubscribedTopics()));

        // InAppMessaging
        PusheInAppMessaging.DisableInAppMessaging();
        PusheUnity.Log("Is in app messaging enabled?" + PusheInAppMessaging.IsInAppMessagingEnabled());
        PusheInAppMessaging.EnableInAppMessaging();
        PusheUnity.Log("Is in app messaging enabled? " + PusheInAppMessaging.IsInAppMessagingEnabled());
        PusheInAppMessaging.TriggerEvent("qqq");
        PusheInAppMessaging.SetInAppMessagingListener(new InAppMessagingListener());

        // FCM token and ...
        var fcmToken      = PusheUnity.GetFcmToken();
        var hmsToken      = PusheUnity.GetHmsToken();
        var activeService = PusheUnity.GetActiveService();

        PusheUnity.Log("Fcm token: " + fcmToken + "\nHms token: " + hmsToken + "\nActive service: " + activeService);

        // Foreground awareness feature of notification
        PusheUnity.Log("Are all notifications aware of foreground state? " + PusheUnity.IsForceForegroundAware());
        PusheUnity.Log("Toggle to true");
        PusheUnity.EnableNotificationForceForegroundAware();
        PusheUnity.Log("Are all notifications aware of foreground state? " + PusheUnity.IsForceForegroundAware());
        PusheUnity.Log("Toggle back to false");
        PusheUnity.DisableNotificationForceForegroundAware();
        PusheUnity.Log("Are all notifications aware of foreground state? " + PusheUnity.IsForceForegroundAware());
    }